41218 lines
2.0 MiB
Plaintext
41218 lines
2.0 MiB
Plaintext
/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
|
|
|* *|
|
|
|* Op Definitions *|
|
|
|* *|
|
|
|* Automatically generated file, do not edit! *|
|
|
|* From: OpenMPOps.td *|
|
|
|* *|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
#ifdef GET_OP_LIST
|
|
#undef GET_OP_LIST
|
|
|
|
::mlir::omp::AffinityEntryOp,
|
|
::mlir::omp::AllocSharedMemOp,
|
|
::mlir::omp::AllocateDirOp,
|
|
::mlir::omp::AllocateFreeOp,
|
|
::mlir::omp::AtomicCaptureOp,
|
|
::mlir::omp::AtomicCompareOp,
|
|
::mlir::omp::AtomicReadOp,
|
|
::mlir::omp::AtomicUpdateOp,
|
|
::mlir::omp::AtomicWriteOp,
|
|
::mlir::omp::BarrierOp,
|
|
::mlir::omp::CancelOp,
|
|
::mlir::omp::CancellationPointOp,
|
|
::mlir::omp::CanonicalLoopOp,
|
|
::mlir::omp::CriticalDeclareOp,
|
|
::mlir::omp::CriticalOp,
|
|
::mlir::omp::DeclareMapperInfoOp,
|
|
::mlir::omp::DeclareMapperOp,
|
|
::mlir::omp::DeclareReductionOp,
|
|
::mlir::omp::DeclareSimdOp,
|
|
::mlir::omp::DistributeOp,
|
|
::mlir::omp::FlushOp,
|
|
::mlir::omp::FreeSharedMemOp,
|
|
::mlir::omp::FuseOp,
|
|
::mlir::omp::GroupprivateOp,
|
|
::mlir::omp::IteratorOp,
|
|
::mlir::omp::LoopNestOp,
|
|
::mlir::omp::LoopOp,
|
|
::mlir::omp::MapBoundsOp,
|
|
::mlir::omp::MapInfoOp,
|
|
::mlir::omp::MaskedOp,
|
|
::mlir::omp::MasterOp,
|
|
::mlir::omp::NewCliOp,
|
|
::mlir::omp::OrderedOp,
|
|
::mlir::omp::OrderedRegionOp,
|
|
::mlir::omp::ParallelOp,
|
|
::mlir::omp::PrivateClauseOp,
|
|
::mlir::omp::ScanOp,
|
|
::mlir::omp::ScopeOp,
|
|
::mlir::omp::SectionOp,
|
|
::mlir::omp::SectionsOp,
|
|
::mlir::omp::SimdOp,
|
|
::mlir::omp::SingleOp,
|
|
::mlir::omp::TargetAllocMemOp,
|
|
::mlir::omp::TargetDataOp,
|
|
::mlir::omp::TargetEnterDataOp,
|
|
::mlir::omp::TargetExitDataOp,
|
|
::mlir::omp::TargetFreeMemOp,
|
|
::mlir::omp::TargetOp,
|
|
::mlir::omp::TargetUpdateOp,
|
|
::mlir::omp::TaskOp,
|
|
::mlir::omp::TaskgroupOp,
|
|
::mlir::omp::TaskloopContextOp,
|
|
::mlir::omp::TaskloopWrapperOp,
|
|
::mlir::omp::TaskwaitOp,
|
|
::mlir::omp::TaskyieldOp,
|
|
::mlir::omp::TeamsOp,
|
|
::mlir::omp::TerminatorOp,
|
|
::mlir::omp::ThreadprivateOp,
|
|
::mlir::omp::TileOp,
|
|
::mlir::omp::UnrollHeuristicOp,
|
|
::mlir::omp::WorkdistributeOp,
|
|
::mlir::omp::WorkshareLoopWrapperOp,
|
|
::mlir::omp::WorkshareOp,
|
|
::mlir::omp::WsloopOp,
|
|
::mlir::omp::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_OpenMPOps1(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((::llvm::isa<::mlir::omp::PointerLikeType>(type)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be OpenMP-compatible variable type, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenMPOps2(
|
|
::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_OpenMPOps3(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((::llvm::isa<::mlir::omp::AffinityEntryType>(type)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be Type for representing omp affinity clause locator information, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenMPOps4(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((type.isSignlessInteger()))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be signless integer, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenMPOps5(
|
|
::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_OpenMPOps6(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((::llvm::isa<::mlir::IntegerType>(type)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be integer, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenMPOps7(
|
|
::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_OpenMPOps8(
|
|
::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_OpenMPOps9(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((::llvm::isa<::mlir::omp::CanonicalLoopInfoType>(type)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be Type for representing a reference to a canonical loop, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenMPOps10(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((::llvm::isa<::mlir::omp::PointerLikeType>(type)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be variadic of OpenMP-compatible variable type, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenMPOps11(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((::llvm::isa<::mlir::omp::IteratedType>(type)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be variadic of OpenMP iterator-produced list handle, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenMPOps12(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((::llvm::isa<::mlir::IntegerType>(type)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be variadic of integer, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenMPOps13(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((::llvm::isa<::mlir::omp::CanonicalLoopInfoType>(type)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be variadic of Type for representing a reference to a canonical loop, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenMPOps14(
|
|
::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_OpenMPOps15(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((::llvm::isa<::mlir::omp::IteratedType>(type)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be OpenMP iterator-produced list handle, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenMPOps16(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((::llvm::isa<::mlir::omp::MapBoundsType>(type)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be Type for representing omp map clause bounds information, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenMPOps17(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((::llvm::isa<::mlir::omp::MapBoundsType>(type)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be variadic of Type for representing omp map clause bounds information, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenMPOps18(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((type.isSignlessInteger(64)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be 64-bit signless integer, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenMPOps19(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((::llvm::isa<::mlir::omp::AffinityEntryType>(type)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be variadic of Type for representing omp affinity clause locator information, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps1(
|
|
::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_OpenMPOps1(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps1(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps2(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getValue().isStrictlyPositive()))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps2(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps2(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps3(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !(((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: 64-bit signless integer attribute";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps3(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps3(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps4(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::ClauseMemoryOrderKindAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: MemoryOrderKind Clause";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps4(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps4(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps5(
|
|
::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_OpenMPOps5(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps5(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps6(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::AtomicControlAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: ";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps6(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps6(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps7(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::ClauseCancellationConstructTypeAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: CancellationConstructType Clause";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps7(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps7(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps8(
|
|
::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_OpenMPOps8(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps8(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps9(
|
|
::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_OpenMPOps9(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps9(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps10(
|
|
::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_OpenMPOps10(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps10(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps11(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::ArrayAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: array attribute";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps11(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps11(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps12(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::ClauseOrderKindAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: OrderKind Clause";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps12(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps12(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps13(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::OrderModifierAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: OpenMP Order Modifier";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps13(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps13(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps14(
|
|
::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_OpenMPOps14(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps14(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps15(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::DeclareTargetDeviceTypeAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: device_type clause";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps15(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps15(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps16(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() >= 1))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: 64-bit signless integer attribute whose minimum value is 1";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps16(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps16(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps17(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: i64 dense array attribute";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps17(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps17(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps18(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::ClauseBindKindAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: BindKind Clause";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps18(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps18(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps19(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::ReductionModifierAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: reduction modifier";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps19(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps19(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps20(
|
|
::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_OpenMPOps20(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps20(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps21(
|
|
::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_OpenMPOps21(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps21(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps22(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::ClauseMapFlagsAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: Map types and modifiers tied to data maps";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps22(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps22(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps23(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::VariableCaptureKindAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: variable capture kind";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps23(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps23(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps24(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); }))); }))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: Array of 64-bit integer array attributes";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps24(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps24(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps25(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::ClauseDependAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: depend clause";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps25(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps25(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps26(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() >= 0))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: 64-bit signless integer attribute whose minimum value is 0";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps26(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps26(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps27(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::ClauseProcBindKindAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: ProcBindKind Clause";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps27(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps27(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps28(
|
|
::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()))) && (!((::llvm::isa<::mlir::TokenType>(::llvm::cast<::mlir::TypeAttr>(attr).getValue()))))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: type attribute of any non-token type";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps28(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps28(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps29(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::DataSharingClauseTypeAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: Type of a data-sharing clause";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps29(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps29(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps30(
|
|
::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::omp::ClauseTaskDependAttr>(attr))); }))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: depend clause in a target or task construct array";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps30(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps30(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps31(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::AccessGroupModifierAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: access group modifier";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps31(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps31(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps32(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::FallbackModifierAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: fallback modifier";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps32(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps32(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps33(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::ClauseGrainsizeTypeAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: GrainsizeType Clause";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps33(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps33(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps34(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::ClauseNumTasksTypeAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: NumTasksType Clause";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps34(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps34(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps35(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::ClauseScheduleKindAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: ScheduleKind Clause";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps35(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps35(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps36(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::omp::ScheduleModifierAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: OpenMP Schedule Modifier";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenMPOps36(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_OpenMPOps36(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_region_constraint_OpenMPOps1(
|
|
::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_OpenMPOps2(
|
|
::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName,
|
|
unsigned regionIndex) {
|
|
if (!((true))) {
|
|
return op->emitOpError("region #") << regionIndex
|
|
<< (regionName.empty() ? " " : " ('" + regionName + "') ")
|
|
<< "failed to verify constraint: any region";
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_region_constraint_OpenMPOps3(
|
|
::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName,
|
|
unsigned regionIndex) {
|
|
if (!((::llvm::hasNItemsOrLess(region, 1)))) {
|
|
return op->emitOpError("region #") << regionIndex
|
|
<< (regionName.empty() ? " " : " ('" + regionName + "') ")
|
|
<< "failed to verify constraint: region with at most 1 blocks";
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::AffinityEntryOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
AffinityEntryOpGenericAdaptorBase::AffinityEntryOpGenericAdaptorBase(AffinityEntryOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
AffinityEntryOpAdaptor::AffinityEntryOpAdaptor(AffinityEntryOp op) : AffinityEntryOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult AffinityEntryOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AffinityEntryOp::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 AffinityEntryOp::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 AffinityEntryOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> AffinityEntryOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void AffinityEntryOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void AffinityEntryOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult AffinityEntryOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AffinityEntryOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type entry, ::mlir::Value addr, ::mlir::Value len) {
|
|
odsState.addOperands(addr);
|
|
odsState.addOperands(len);
|
|
odsState.addTypes(entry);
|
|
}
|
|
|
|
AffinityEntryOp AffinityEntryOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type entry, ::mlir::Value addr, ::mlir::Value len) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(entry)>(entry), std::forward<decltype(addr)>(addr), std::forward<decltype(len)>(len));
|
|
auto __res__ = ::llvm::dyn_cast<AffinityEntryOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AffinityEntryOp AffinityEntryOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type entry, ::mlir::Value addr, ::mlir::Value len) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(entry)>(entry), std::forward<decltype(addr)>(addr), std::forward<decltype(len)>(len));
|
|
}
|
|
|
|
void AffinityEntryOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value len) {
|
|
odsState.addOperands(addr);
|
|
odsState.addOperands(len);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AffinityEntryOp AffinityEntryOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value len) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(addr)>(addr), std::forward<decltype(len)>(len));
|
|
auto __res__ = ::llvm::dyn_cast<AffinityEntryOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AffinityEntryOp AffinityEntryOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value len) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(addr)>(addr), std::forward<decltype(len)>(len));
|
|
}
|
|
|
|
void AffinityEntryOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AffinityEntryOp AffinityEntryOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<AffinityEntryOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AffinityEntryOp AffinityEntryOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void AffinityEntryOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AffinityEntryOp AffinityEntryOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<AffinityEntryOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AffinityEntryOp AffinityEntryOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult AffinityEntryOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps2(*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_OpenMPOps3(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AffinityEntryOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult AffinityEntryOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::OpAsmParser::UnresolvedOperand addrRawOperand{};
|
|
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> addrOperands(&addrRawOperand, 1); ::llvm::SMLoc addrOperandsLoc;
|
|
(void)addrOperandsLoc;
|
|
::mlir::OpAsmParser::UnresolvedOperand lenRawOperand{};
|
|
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lenOperands(&lenRawOperand, 1); ::llvm::SMLoc lenOperandsLoc;
|
|
(void)lenOperandsLoc;
|
|
::mlir::Type addrRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> addrTypes(&addrRawType, 1);
|
|
::mlir::Type lenRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> lenTypes(&lenRawType, 1);
|
|
::mlir::Type entryRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> entryTypes(&entryRawType, 1);
|
|
|
|
addrOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperand(addrRawOperand))
|
|
return ::mlir::failure();
|
|
if (parser.parseComma())
|
|
return ::mlir::failure();
|
|
|
|
lenOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperand(lenRawOperand))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
::mlir::omp::PointerLikeType type;
|
|
if (parser.parseCustomTypeWithFallback(type))
|
|
return ::mlir::failure();
|
|
addrRawType = type;
|
|
}
|
|
if (parser.parseComma())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
::mlir::Type type;
|
|
if (parser.parseCustomTypeWithFallback(type))
|
|
return ::mlir::failure();
|
|
lenRawType = type;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
if (parser.parseArrow())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseType(entryRawType))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
|
|
return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
|
|
})))
|
|
return ::mlir::failure();
|
|
}
|
|
result.addTypes(entryTypes);
|
|
if (parser.resolveOperands(addrOperands, addrTypes, addrOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(lenOperands, lenTypes, lenOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AffinityEntryOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getAddr();
|
|
_odsPrinter << ",";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getLen();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ' << "(";
|
|
{
|
|
auto type = getAddr().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::omp::PointerLikeType>(type))
|
|
_odsPrinter.printStrippedAttrOrType(validType);
|
|
else
|
|
_odsPrinter << type;
|
|
}
|
|
_odsPrinter << ",";
|
|
_odsPrinter << ' ';
|
|
{
|
|
auto type = getLen().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type))
|
|
_odsPrinter.printStrippedAttrOrType(validType);
|
|
else
|
|
_odsPrinter << type;
|
|
}
|
|
_odsPrinter << ")";
|
|
_odsPrinter << ' ' << "->";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getEntry().getType();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
void AffinityEntryOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::AffinityEntryOp)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::AllocSharedMemOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
AllocSharedMemOpGenericAdaptorBase::AllocSharedMemOpGenericAdaptorBase(AllocSharedMemOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::Type AllocSharedMemOpGenericAdaptorBase::getMemElemType() {
|
|
auto attr = getMemElemTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::std::optional<uint64_t> AllocSharedMemOpGenericAdaptorBase::getMemAlignment() {
|
|
auto attr = getMemAlignmentAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
AllocSharedMemOpAdaptor::AllocSharedMemOpAdaptor(AllocSharedMemOp op) : AllocSharedMemOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult AllocSharedMemOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_mem_alignment = getProperties().mem_alignment; (void)tblgen_mem_alignment;
|
|
auto tblgen_mem_elem_type = getProperties().mem_elem_type; (void)tblgen_mem_elem_type;
|
|
if (!tblgen_mem_elem_type) return emitError(loc, "'omp.alloc_shared_mem' op requires attribute 'mem_elem_type'");
|
|
|
|
if (tblgen_mem_elem_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_mem_elem_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_mem_elem_type).getValue()))) && ((true))))
|
|
return emitError(loc, "'omp.alloc_shared_mem' op attribute 'mem_elem_type' failed to satisfy constraint: any type attribute");
|
|
|
|
if (tblgen_mem_alignment && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_mem_alignment))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_mem_alignment).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_mem_alignment).getValue().isStrictlyPositive()))))
|
|
return emitError(loc, "'omp.alloc_shared_mem' op attribute 'mem_alignment' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AllocSharedMemOp::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.mem_alignment;
|
|
auto attr = dict.get("mem_alignment");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `mem_alignment` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.mem_elem_type;
|
|
auto attr = dict.get("mem_elem_type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `mem_elem_type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute AllocSharedMemOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.mem_alignment;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("mem_alignment",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.mem_elem_type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("mem_elem_type",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code AllocSharedMemOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.mem_alignment.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.mem_elem_type.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> AllocSharedMemOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "mem_alignment")
|
|
return prop.mem_alignment;
|
|
|
|
if (name == "mem_elem_type")
|
|
return prop.mem_elem_type;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void AllocSharedMemOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "mem_alignment") {
|
|
prop.mem_alignment = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.mem_alignment)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "mem_elem_type") {
|
|
prop.mem_elem_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.mem_elem_type)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void AllocSharedMemOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.mem_alignment) attrs.append("mem_alignment", prop.mem_alignment);
|
|
|
|
if (prop.mem_elem_type) attrs.append("mem_elem_type", prop.mem_elem_type);
|
|
}
|
|
|
|
::llvm::LogicalResult AllocSharedMemOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMemAlignmentAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps2(attr, "mem_alignment", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMemElemTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(attr, "mem_elem_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AllocSharedMemOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.mem_alignment)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.mem_elem_type)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AllocSharedMemOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.mem_alignment);
|
|
writer.writeAttribute(prop.mem_elem_type);
|
|
}
|
|
|
|
::mlir::Type AllocSharedMemOp::getMemElemType() {
|
|
auto attr = getMemElemTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::std::optional<uint64_t> AllocSharedMemOp::getMemAlignment() {
|
|
auto attr = getMemAlignmentAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
void AllocSharedMemOp::setMemElemType(::mlir::Type attrValue) {
|
|
getProperties().mem_elem_type = ::mlir::TypeAttr::get(attrValue);
|
|
}
|
|
|
|
void AllocSharedMemOp::setMemAlignment(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().mem_alignment;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void AllocSharedMemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::TypeAttr mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment) {
|
|
odsState.addOperands(mem_array_size);
|
|
odsState.getOrAddProperties<Properties>().mem_elem_type = mem_elem_type;
|
|
if (mem_alignment) {
|
|
odsState.getOrAddProperties<Properties>().mem_alignment = mem_alignment;
|
|
}
|
|
odsState.addTypes(resultType0);
|
|
}
|
|
|
|
AllocSharedMemOp AllocSharedMemOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type resultType0, ::mlir::TypeAttr mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultType0)>(resultType0), std::forward<decltype(mem_elem_type)>(mem_elem_type), std::forward<decltype(mem_array_size)>(mem_array_size), std::forward<decltype(mem_alignment)>(mem_alignment));
|
|
auto __res__ = ::llvm::dyn_cast<AllocSharedMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AllocSharedMemOp AllocSharedMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type resultType0, ::mlir::TypeAttr mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultType0)>(resultType0), std::forward<decltype(mem_elem_type)>(mem_elem_type), std::forward<decltype(mem_array_size)>(mem_array_size), std::forward<decltype(mem_alignment)>(mem_alignment));
|
|
}
|
|
|
|
void AllocSharedMemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::TypeAttr mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment) {
|
|
odsState.addOperands(mem_array_size);
|
|
odsState.getOrAddProperties<Properties>().mem_elem_type = mem_elem_type;
|
|
if (mem_alignment) {
|
|
odsState.getOrAddProperties<Properties>().mem_alignment = mem_alignment;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AllocSharedMemOp AllocSharedMemOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::TypeAttr mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(mem_elem_type)>(mem_elem_type), std::forward<decltype(mem_array_size)>(mem_array_size), std::forward<decltype(mem_alignment)>(mem_alignment));
|
|
auto __res__ = ::llvm::dyn_cast<AllocSharedMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AllocSharedMemOp AllocSharedMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::TypeAttr mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(mem_elem_type)>(mem_elem_type), std::forward<decltype(mem_array_size)>(mem_array_size), std::forward<decltype(mem_alignment)>(mem_alignment));
|
|
}
|
|
|
|
void AllocSharedMemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Type mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment) {
|
|
odsState.addOperands(mem_array_size);
|
|
odsState.getOrAddProperties<Properties>().mem_elem_type = ::mlir::TypeAttr::get(mem_elem_type);
|
|
if (mem_alignment) {
|
|
odsState.getOrAddProperties<Properties>().mem_alignment = mem_alignment;
|
|
}
|
|
odsState.addTypes(resultType0);
|
|
}
|
|
|
|
AllocSharedMemOp AllocSharedMemOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type resultType0, ::mlir::Type mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultType0)>(resultType0), std::forward<decltype(mem_elem_type)>(mem_elem_type), std::forward<decltype(mem_array_size)>(mem_array_size), std::forward<decltype(mem_alignment)>(mem_alignment));
|
|
auto __res__ = ::llvm::dyn_cast<AllocSharedMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AllocSharedMemOp AllocSharedMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type resultType0, ::mlir::Type mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultType0)>(resultType0), std::forward<decltype(mem_elem_type)>(mem_elem_type), std::forward<decltype(mem_array_size)>(mem_array_size), std::forward<decltype(mem_alignment)>(mem_alignment));
|
|
}
|
|
|
|
void AllocSharedMemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Type mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment) {
|
|
odsState.addOperands(mem_array_size);
|
|
odsState.getOrAddProperties<Properties>().mem_elem_type = ::mlir::TypeAttr::get(mem_elem_type);
|
|
if (mem_alignment) {
|
|
odsState.getOrAddProperties<Properties>().mem_alignment = mem_alignment;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AllocSharedMemOp AllocSharedMemOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Type mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(mem_elem_type)>(mem_elem_type), std::forward<decltype(mem_array_size)>(mem_array_size), std::forward<decltype(mem_alignment)>(mem_alignment));
|
|
auto __res__ = ::llvm::dyn_cast<AllocSharedMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AllocSharedMemOp AllocSharedMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Type mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(mem_elem_type)>(mem_elem_type), std::forward<decltype(mem_array_size)>(mem_array_size), std::forward<decltype(mem_alignment)>(mem_alignment));
|
|
}
|
|
|
|
void AllocSharedMemOp::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<AllocSharedMemOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
AllocSharedMemOp AllocSharedMemOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<AllocSharedMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AllocSharedMemOp AllocSharedMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void AllocSharedMemOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AllocSharedMemOp AllocSharedMemOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<AllocSharedMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AllocSharedMemOp AllocSharedMemOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult AllocSharedMemOp::verifyInvariantsImpl() {
|
|
auto tblgen_mem_alignment = getProperties().mem_alignment; (void)tblgen_mem_alignment;
|
|
auto tblgen_mem_elem_type = getProperties().mem_elem_type; (void)tblgen_mem_elem_type;
|
|
if (!tblgen_mem_elem_type) return emitOpError("requires attribute 'mem_elem_type'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(*this, tblgen_mem_elem_type, "mem_elem_type")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps2(*this, tblgen_mem_alignment, "mem_alignment")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps4(*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_OpenMPOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AllocSharedMemOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult AllocSharedMemOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::OpAsmParser::UnresolvedOperand mem_array_sizeRawOperand{};
|
|
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> mem_array_sizeOperands(&mem_array_sizeRawOperand, 1); ::llvm::SMLoc mem_array_sizeOperandsLoc;
|
|
(void)mem_array_sizeOperandsLoc;
|
|
::mlir::TypeAttr mem_elem_typeAttr;
|
|
::mlir::Type mem_array_sizeRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> mem_array_sizeTypes(&mem_array_sizeRawType, 1);
|
|
::mlir::IntegerAttr mem_alignmentAttr;
|
|
::llvm::SmallVector<::mlir::Type, 1> allResultTypes;
|
|
|
|
mem_array_sizeOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperand(mem_array_sizeRawOperand))
|
|
return ::mlir::failure();
|
|
if (parser.parseKeyword("x"))
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseCustomAttributeWithFallback(mem_elem_typeAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
|
|
return ::mlir::failure();
|
|
}
|
|
if (mem_elem_typeAttr) result.getOrAddProperties<AllocSharedMemOp::Properties>().mem_elem_type = mem_elem_typeAttr;
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
::mlir::IntegerType type;
|
|
if (parser.parseCustomTypeWithFallback(type))
|
|
return ::mlir::failure();
|
|
mem_array_sizeRawType = type;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
bool alignClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("align"))) {
|
|
|
|
if (alignClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`align` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
alignClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
::mlir::OptionalParseResult parseResultmem_alignmentAttr =
|
|
parser.parseOptionalAttribute(mem_alignmentAttr, parser.getBuilder().getIntegerType(64));
|
|
if (parseResultmem_alignmentAttr.has_value() && failed(*parseResultmem_alignmentAttr))
|
|
return ::mlir::failure();
|
|
if (parseResultmem_alignmentAttr.has_value() && succeeded(*parseResultmem_alignmentAttr))
|
|
if (mem_alignmentAttr) result.getOrAddProperties<AllocSharedMemOp::Properties>().mem_alignment = mem_alignmentAttr;
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
if (parser.parseArrow())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(allResultTypes))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
|
|
return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
|
|
})))
|
|
return ::mlir::failure();
|
|
}
|
|
result.addTypes(allResultTypes);
|
|
if (parser.resolveOperands(mem_array_sizeOperands, mem_array_sizeTypes, mem_array_sizeOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AllocSharedMemOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getMemArraySize();
|
|
_odsPrinter << ' ' << "x";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printAttributeWithoutType(getMemElemTypeAttr());
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ' << "(";
|
|
{
|
|
auto type = getMemArraySize().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type))
|
|
_odsPrinter.printStrippedAttrOrType(validType);
|
|
else
|
|
_odsPrinter << type;
|
|
}
|
|
_odsPrinter << ")";
|
|
if (false || (getMemAlignmentAttr())) {
|
|
_odsPrinter << ' ' << "align";
|
|
_odsPrinter << "(";
|
|
_odsPrinter.printAttributeWithoutType(getMemAlignmentAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ' << "->";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getResultTypes();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("mem_elem_type");
|
|
elidedAttrs.push_back("mem_alignment");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
void AllocSharedMemOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
effects.emplace_back(::mlir::MemoryEffects::Allocate::get(), 0, false, ::mlir::SideEffects::DefaultResource::get());
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::AllocSharedMemOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::AllocSharedMemOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::AllocateDirOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
AllocateDirOpGenericAdaptorBase::AllocateDirOpGenericAdaptorBase(AllocateDirOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> AllocateDirOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::std::optional<uint64_t> AllocateDirOpGenericAdaptorBase::getAlign() {
|
|
auto attr = getAlignAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
AllocateDirOpAdaptor::AllocateDirOpAdaptor(AllocateDirOp op) : AllocateDirOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult AllocateDirOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_align = getProperties().align; (void)tblgen_align;
|
|
|
|
if (tblgen_align && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_align))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_align).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_align).getValue().isStrictlyPositive()))))
|
|
return emitError(loc, "'omp.allocate_dir' op attribute 'align' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> AllocateDirOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange AllocateDirOp::getVarListMutable() {
|
|
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 AllocateDirOp::getAllocatorMutable() {
|
|
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 AllocateDirOp::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.align;
|
|
auto attr = dict.get("align");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `align` 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 AllocateDirOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.align;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("align",
|
|
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 AllocateDirOp::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.align.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> AllocateDirOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "align")
|
|
return prop.align;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void AllocateDirOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "align") {
|
|
prop.align = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.align)>>(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 AllocateDirOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.align) attrs.append("align", prop.align);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult AllocateDirOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAlignAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps2(attr, "align", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AllocateDirOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.align)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(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 AllocateDirOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.align);
|
|
|
|
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<uint64_t> AllocateDirOp::getAlign() {
|
|
auto attr = getAlignAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
void AllocateDirOp::setAlign(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().align;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void AllocateDirOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange varList, /*optional*/::mlir::IntegerAttr align, /*optional*/::mlir::Value allocator) {
|
|
odsState.addOperands(varList);
|
|
if (allocator)
|
|
odsState.addOperands(allocator);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(varList.size()), (allocator ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (align) {
|
|
odsState.getOrAddProperties<Properties>().align = align;
|
|
}
|
|
}
|
|
|
|
AllocateDirOp AllocateDirOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange varList, /*optional*/::mlir::IntegerAttr align, /*optional*/::mlir::Value allocator) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(varList)>(varList), std::forward<decltype(align)>(align), std::forward<decltype(allocator)>(allocator));
|
|
auto __res__ = ::llvm::dyn_cast<AllocateDirOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AllocateDirOp AllocateDirOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange varList, /*optional*/::mlir::IntegerAttr align, /*optional*/::mlir::Value allocator) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(varList)>(varList), std::forward<decltype(align)>(align), std::forward<decltype(allocator)>(allocator));
|
|
}
|
|
|
|
void AllocateDirOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange varList, /*optional*/::mlir::IntegerAttr align, /*optional*/::mlir::Value allocator) {
|
|
odsState.addOperands(varList);
|
|
if (allocator)
|
|
odsState.addOperands(allocator);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(varList.size()), (allocator ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (align) {
|
|
odsState.getOrAddProperties<Properties>().align = align;
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AllocateDirOp AllocateDirOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange varList, /*optional*/::mlir::IntegerAttr align, /*optional*/::mlir::Value allocator) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(varList)>(varList), std::forward<decltype(align)>(align), std::forward<decltype(allocator)>(allocator));
|
|
auto __res__ = ::llvm::dyn_cast<AllocateDirOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AllocateDirOp AllocateDirOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange varList, /*optional*/::mlir::IntegerAttr align, /*optional*/::mlir::Value allocator) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(varList)>(varList), std::forward<decltype(align)>(align), std::forward<decltype(allocator)>(allocator));
|
|
}
|
|
|
|
void AllocateDirOp::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<AllocateDirOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
AllocateDirOp AllocateDirOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<AllocateDirOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AllocateDirOp AllocateDirOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void AllocateDirOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AllocateDirOp AllocateDirOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<AllocateDirOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AllocateDirOp AllocateDirOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult AllocateDirOp::verifyInvariantsImpl() {
|
|
auto tblgen_align = getProperties().align; (void)tblgen_align;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps2(*this, tblgen_align, "align")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*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_OpenMPOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AllocateDirOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult AllocateDirOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varListOperands;
|
|
::llvm::SMLoc varListOperandsLoc;
|
|
(void)varListOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> varListTypes;
|
|
::mlir::IntegerAttr alignAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocatorOperands;
|
|
::llvm::SMLoc allocatorOperandsLoc;
|
|
(void)allocatorOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocatorTypes;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
varListOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(varListOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(varListTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
bool alignClause = false;
|
|
bool allocatorClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("align"))) {
|
|
|
|
if (alignClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`align` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
alignClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
::mlir::OptionalParseResult parseResultalignAttr =
|
|
parser.parseOptionalAttribute(alignAttr, parser.getBuilder().getIntegerType(64));
|
|
if (parseResultalignAttr.has_value() && failed(*parseResultalignAttr))
|
|
return ::mlir::failure();
|
|
if (parseResultalignAttr.has_value() && succeeded(*parseResultalignAttr))
|
|
if (alignAttr) result.getOrAddProperties<AllocateDirOp::Properties>().align = alignAttr;
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("allocator"))) {
|
|
|
|
if (allocatorClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`allocator` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
allocatorClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
allocatorOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
allocatorOperands.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();
|
|
allocatorTypes.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<int32_t>({static_cast<int32_t>(varListOperands.size()), static_cast<int32_t>(allocatorOperands.size())}), result.getOrAddProperties<AllocateDirOp::Properties>().operandSegmentSizes.begin());
|
|
if (parser.resolveOperands(varListOperands, varListTypes, varListOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!allocatorOperands.empty()) {
|
|
if (parser.resolveOperands(allocatorOperands, allocatorTypes, allocatorOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AllocateDirOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getVarList();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getVarList().getTypes();
|
|
_odsPrinter << ")";
|
|
if (false || (getAlignAttr())) {
|
|
_odsPrinter << ' ' << "align";
|
|
_odsPrinter << "(";
|
|
_odsPrinter.printAttributeWithoutType(getAlignAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getAllocator()) {
|
|
_odsPrinter << ' ' << "allocator";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getAllocator())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << (getAllocator() ? ::llvm::ArrayRef<::mlir::Type>(getAllocator().getType()) : ::llvm::ArrayRef<::mlir::Type>());
|
|
_odsPrinter << ")";
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("align");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::AllocateDirOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::AllocateDirOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::AllocateFreeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
AllocateFreeOpGenericAdaptorBase::AllocateFreeOpGenericAdaptorBase(AllocateFreeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> AllocateFreeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
AllocateFreeOpAdaptor::AllocateFreeOpAdaptor(AllocateFreeOp op) : AllocateFreeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult AllocateFreeOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> AllocateFreeOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange AllocateFreeOp::getVarListMutable() {
|
|
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 AllocateFreeOp::getAllocatorMutable() {
|
|
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 AllocateFreeOp::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 AllocateFreeOp::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 AllocateFreeOp::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<mlir::Attribute> AllocateFreeOp::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 AllocateFreeOp::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 AllocateFreeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult AllocateFreeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AllocateFreeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(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 AllocateFreeOp::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 AllocateFreeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange varList, /*optional*/::mlir::Value allocator) {
|
|
odsState.addOperands(varList);
|
|
if (allocator)
|
|
odsState.addOperands(allocator);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(varList.size()), (allocator ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
}
|
|
|
|
AllocateFreeOp AllocateFreeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange varList, /*optional*/::mlir::Value allocator) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(varList)>(varList), std::forward<decltype(allocator)>(allocator));
|
|
auto __res__ = ::llvm::dyn_cast<AllocateFreeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AllocateFreeOp AllocateFreeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange varList, /*optional*/::mlir::Value allocator) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(varList)>(varList), std::forward<decltype(allocator)>(allocator));
|
|
}
|
|
|
|
void AllocateFreeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange varList, /*optional*/::mlir::Value allocator) {
|
|
odsState.addOperands(varList);
|
|
if (allocator)
|
|
odsState.addOperands(allocator);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(varList.size()), (allocator ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AllocateFreeOp AllocateFreeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange varList, /*optional*/::mlir::Value allocator) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(varList)>(varList), std::forward<decltype(allocator)>(allocator));
|
|
auto __res__ = ::llvm::dyn_cast<AllocateFreeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AllocateFreeOp AllocateFreeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange varList, /*optional*/::mlir::Value allocator) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(varList)>(varList), std::forward<decltype(allocator)>(allocator));
|
|
}
|
|
|
|
void AllocateFreeOp::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<AllocateFreeOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
AllocateFreeOp AllocateFreeOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<AllocateFreeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AllocateFreeOp AllocateFreeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void AllocateFreeOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AllocateFreeOp AllocateFreeOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<AllocateFreeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AllocateFreeOp AllocateFreeOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult AllocateFreeOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*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_OpenMPOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AllocateFreeOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult AllocateFreeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varListOperands;
|
|
::llvm::SMLoc varListOperandsLoc;
|
|
(void)varListOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> varListTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocatorOperands;
|
|
::llvm::SMLoc allocatorOperandsLoc;
|
|
(void)allocatorOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocatorTypes;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
varListOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(varListOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(varListTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
bool allocatorClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("allocator"))) {
|
|
|
|
if (allocatorClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`allocator` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
allocatorClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
allocatorOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
allocatorOperands.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();
|
|
allocatorTypes.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<int32_t>({static_cast<int32_t>(varListOperands.size()), static_cast<int32_t>(allocatorOperands.size())}), result.getOrAddProperties<AllocateFreeOp::Properties>().operandSegmentSizes.begin());
|
|
if (parser.resolveOperands(varListOperands, varListTypes, varListOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!allocatorOperands.empty()) {
|
|
if (parser.resolveOperands(allocatorOperands, allocatorTypes, allocatorOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AllocateFreeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getVarList();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getVarList().getTypes();
|
|
_odsPrinter << ")";
|
|
if (false || getAllocator()) {
|
|
_odsPrinter << ' ' << "allocator";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getAllocator())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << (getAllocator() ? ::llvm::ArrayRef<::mlir::Type>(getAllocator().getType()) : ::llvm::ArrayRef<::mlir::Type>());
|
|
_odsPrinter << ")";
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::AllocateFreeOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::AllocateFreeOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::AtomicCaptureOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
AtomicCaptureOpGenericAdaptorBase::AtomicCaptureOpGenericAdaptorBase(AtomicCaptureOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::IntegerAttr AtomicCaptureOpGenericAdaptorBase::getHintAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().hint);
|
|
if (!attr)
|
|
attr = ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(64), 0);
|
|
return attr;
|
|
}
|
|
|
|
uint64_t AtomicCaptureOpGenericAdaptorBase::getHint() {
|
|
auto attr = getHintAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(64), 0).getValue().getZExtValue();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseMemoryOrderKind> AtomicCaptureOpGenericAdaptorBase::getMemoryOrder() {
|
|
auto attr = getMemoryOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseMemoryOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
AtomicCaptureOpAdaptor::AtomicCaptureOpAdaptor(AtomicCaptureOp op) : AtomicCaptureOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult AtomicCaptureOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_hint = getProperties().hint; (void)tblgen_hint;
|
|
auto tblgen_memory_order = getProperties().memory_order; (void)tblgen_memory_order;
|
|
|
|
if (tblgen_hint && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_hint))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_hint).getType().isSignlessInteger(64)))))
|
|
return emitError(loc, "'omp.atomic.capture' op attribute 'hint' failed to satisfy constraint: 64-bit signless integer attribute");
|
|
|
|
if (tblgen_memory_order && !((::llvm::isa<::mlir::omp::ClauseMemoryOrderKindAttr>(tblgen_memory_order))))
|
|
return emitError(loc, "'omp.atomic.capture' op attribute 'memory_order' failed to satisfy constraint: MemoryOrderKind Clause");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::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();
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.hint;
|
|
auto attr = dict.get("hint");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `hint` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.memory_order;
|
|
auto attr = dict.get("memory_order");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `memory_order` in property conversion: " << attr;
|
|
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};
|
|
|
|
{
|
|
const auto &propStorage = prop.hint;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("hint",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.memory_order;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("memory_order",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code AtomicCaptureOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.hint.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.memory_order.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> AtomicCaptureOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "hint")
|
|
return prop.hint;
|
|
|
|
if (name == "memory_order")
|
|
return prop.memory_order;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void AtomicCaptureOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "hint") {
|
|
prop.hint = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.hint)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "memory_order") {
|
|
prop.memory_order = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.memory_order)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void AtomicCaptureOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.hint) attrs.append("hint", prop.hint);
|
|
|
|
if (prop.memory_order) attrs.append("memory_order", prop.memory_order);
|
|
}
|
|
|
|
::llvm::LogicalResult AtomicCaptureOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getHintAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps3(attr, "hint", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMemoryOrderAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps4(attr, "memory_order", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AtomicCaptureOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.hint)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.memory_order)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AtomicCaptureOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.hint);
|
|
|
|
writer.writeOptionalAttribute(prop.memory_order);
|
|
}
|
|
|
|
uint64_t AtomicCaptureOp::getHint() {
|
|
auto attr = getHintAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), 0).getValue().getZExtValue();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseMemoryOrderKind> AtomicCaptureOp::getMemoryOrder() {
|
|
auto attr = getMemoryOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseMemoryOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
void AtomicCaptureOp::setHint(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().hint;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void AtomicCaptureOp::setMemoryOrder(::std::optional<::mlir::omp::ClauseMemoryOrderKind> attrValue) {
|
|
auto &odsProp = getProperties().memory_order;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ClauseMemoryOrderKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void AtomicCaptureOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
if (hint) {
|
|
odsState.getOrAddProperties<Properties>().hint = hint;
|
|
}
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
AtomicCaptureOp AtomicCaptureOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicCaptureOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AtomicCaptureOp AtomicCaptureOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicCaptureOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
if (hint) {
|
|
odsState.getOrAddProperties<Properties>().hint = hint;
|
|
}
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
(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::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicCaptureOp>(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::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicCaptureOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.getOrAddProperties<Properties>().hint = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), hint);
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
AtomicCaptureOp AtomicCaptureOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicCaptureOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AtomicCaptureOp AtomicCaptureOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicCaptureOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.getOrAddProperties<Properties>().hint = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), hint);
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
(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*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicCaptureOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AtomicCaptureOp AtomicCaptureOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicCaptureOp::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<AtomicCaptureOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicCaptureOp>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void AtomicCaptureOp::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&>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicCaptureOp>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult AtomicCaptureOp::verifyInvariantsImpl() {
|
|
auto tblgen_hint = getProperties().hint; (void)tblgen_hint;
|
|
auto tblgen_memory_order = getProperties().memory_order; (void)tblgen_memory_order;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps3(*this, tblgen_hint, "hint")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps4(*this, tblgen_memory_order, "memory_order")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps1(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AtomicCaptureOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult AtomicCaptureOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::IntegerAttr hintAttr;
|
|
::mlir::omp::ClauseMemoryOrderKindAttr memory_orderAttr;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
bool hintClause = false;
|
|
bool memory_orderClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("hint"))) {
|
|
|
|
if (hintClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`hint` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
hintClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseSynchronizationHint(parser, hintAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (hintAttr)
|
|
result.getOrAddProperties<AtomicCaptureOp::Properties>().hint = hintAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("memory_order"))) {
|
|
|
|
if (memory_orderClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`memory_order` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
memory_orderClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseClauseAttr(parser, memory_orderAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (memory_orderAttr)
|
|
result.getOrAddProperties<AtomicCaptureOp::Properties>().memory_order = memory_orderAttr;
|
|
}
|
|
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));
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AtomicCaptureOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || ((getHintAttr() && getHintAttr() != ::mlir::OpBuilder((*this)->getContext()).getIntegerAttr(::mlir::OpBuilder((*this)->getContext()).getIntegerType(64), 0)))) {
|
|
_odsPrinter << ' ' << "hint";
|
|
_odsPrinter << "(";
|
|
printSynchronizationHint(_odsPrinter, *this, getHintAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getMemoryOrderAttr())) {
|
|
_odsPrinter << ' ' << "memory_order";
|
|
_odsPrinter << "(";
|
|
printClauseAttr(_odsPrinter, *this, getMemoryOrderAttr());
|
|
_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;
|
|
elidedAttrs.push_back("hint");
|
|
elidedAttrs.push_back("memory_order");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getHintAttr();
|
|
if(attr && (attr == odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), 0)))
|
|
elidedAttrs.push_back("hint");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::AtomicCaptureOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::AtomicCaptureOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::AtomicCompareOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
AtomicCompareOpGenericAdaptorBase::AtomicCompareOpGenericAdaptorBase(AtomicCompareOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::UnitAttr AtomicCompareOpGenericAdaptorBase::getWeakAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().weak);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool AtomicCompareOpGenericAdaptorBase::getWeak() {
|
|
auto attr = getWeakAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::mlir::IntegerAttr AtomicCompareOpGenericAdaptorBase::getHintAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().hint);
|
|
if (!attr)
|
|
attr = ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(64), 0);
|
|
return attr;
|
|
}
|
|
|
|
uint64_t AtomicCompareOpGenericAdaptorBase::getHint() {
|
|
auto attr = getHintAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(64), 0).getValue().getZExtValue();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseMemoryOrderKind> AtomicCompareOpGenericAdaptorBase::getMemoryOrder() {
|
|
auto attr = getMemoryOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseMemoryOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
AtomicCompareOpAdaptor::AtomicCompareOpAdaptor(AtomicCompareOp op) : AtomicCompareOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult AtomicCompareOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_hint = getProperties().hint; (void)tblgen_hint;
|
|
auto tblgen_memory_order = getProperties().memory_order; (void)tblgen_memory_order;
|
|
auto tblgen_weak = getProperties().weak; (void)tblgen_weak;
|
|
|
|
if (tblgen_weak && !((::llvm::isa<::mlir::UnitAttr>(tblgen_weak))))
|
|
return emitError(loc, "'omp.atomic.compare' op attribute 'weak' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_hint && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_hint))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_hint).getType().isSignlessInteger(64)))))
|
|
return emitError(loc, "'omp.atomic.compare' op attribute 'hint' failed to satisfy constraint: 64-bit signless integer attribute");
|
|
|
|
if (tblgen_memory_order && !((::llvm::isa<::mlir::omp::ClauseMemoryOrderKindAttr>(tblgen_memory_order))))
|
|
return emitError(loc, "'omp.atomic.compare' op attribute 'memory_order' failed to satisfy constraint: MemoryOrderKind Clause");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AtomicCompareOp::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.hint;
|
|
auto attr = dict.get("hint");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `hint` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.memory_order;
|
|
auto attr = dict.get("memory_order");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `memory_order` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.weak;
|
|
auto attr = dict.get("weak");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `weak` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute AtomicCompareOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.hint;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("hint",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.memory_order;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("memory_order",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.weak;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("weak",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code AtomicCompareOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.hint.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.memory_order.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.weak.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> AtomicCompareOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "hint")
|
|
return prop.hint;
|
|
|
|
if (name == "memory_order")
|
|
return prop.memory_order;
|
|
|
|
if (name == "weak")
|
|
return prop.weak;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void AtomicCompareOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "hint") {
|
|
prop.hint = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.hint)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "memory_order") {
|
|
prop.memory_order = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.memory_order)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "weak") {
|
|
prop.weak = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.weak)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void AtomicCompareOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.hint) attrs.append("hint", prop.hint);
|
|
|
|
if (prop.memory_order) attrs.append("memory_order", prop.memory_order);
|
|
|
|
if (prop.weak) attrs.append("weak", prop.weak);
|
|
}
|
|
|
|
::llvm::LogicalResult AtomicCompareOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getHintAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps3(attr, "hint", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMemoryOrderAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps4(attr, "memory_order", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getWeakAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "weak", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AtomicCompareOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.hint)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.memory_order)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.weak)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AtomicCompareOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.hint);
|
|
|
|
writer.writeOptionalAttribute(prop.memory_order);
|
|
|
|
writer.writeOptionalAttribute(prop.weak);
|
|
}
|
|
|
|
bool AtomicCompareOp::getWeak() {
|
|
auto attr = getWeakAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
uint64_t AtomicCompareOp::getHint() {
|
|
auto attr = getHintAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), 0).getValue().getZExtValue();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseMemoryOrderKind> AtomicCompareOp::getMemoryOrder() {
|
|
auto attr = getMemoryOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseMemoryOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
void AtomicCompareOp::setWeak(bool attrValue) {
|
|
auto &odsProp = getProperties().weak;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void AtomicCompareOp::setHint(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().hint;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void AtomicCompareOp::setMemoryOrder(::std::optional<::mlir::omp::ClauseMemoryOrderKind> attrValue) {
|
|
auto &odsProp = getProperties().memory_order;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ClauseMemoryOrderKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void AtomicCompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, /*optional*/::mlir::UnitAttr weak, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.addOperands(x);
|
|
if (weak) {
|
|
odsState.getOrAddProperties<Properties>().weak = weak;
|
|
}
|
|
if (hint) {
|
|
odsState.getOrAddProperties<Properties>().hint = hint;
|
|
}
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
AtomicCompareOp AtomicCompareOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value x, /*optional*/::mlir::UnitAttr weak, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(x)>(x), std::forward<decltype(weak)>(weak), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicCompareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AtomicCompareOp AtomicCompareOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value x, /*optional*/::mlir::UnitAttr weak, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(x)>(x), std::forward<decltype(weak)>(weak), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicCompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, /*optional*/::mlir::UnitAttr weak, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.addOperands(x);
|
|
if (weak) {
|
|
odsState.getOrAddProperties<Properties>().weak = weak;
|
|
}
|
|
if (hint) {
|
|
odsState.getOrAddProperties<Properties>().hint = hint;
|
|
}
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AtomicCompareOp AtomicCompareOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value x, /*optional*/::mlir::UnitAttr weak, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(x)>(x), std::forward<decltype(weak)>(weak), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicCompareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AtomicCompareOp AtomicCompareOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value x, /*optional*/::mlir::UnitAttr weak, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(x)>(x), std::forward<decltype(weak)>(weak), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicCompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, /*optional*/bool weak, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.addOperands(x);
|
|
if (weak) {
|
|
odsState.getOrAddProperties<Properties>().weak = ((weak) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
odsState.getOrAddProperties<Properties>().hint = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), hint);
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
AtomicCompareOp AtomicCompareOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value x, /*optional*/bool weak, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(x)>(x), std::forward<decltype(weak)>(weak), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicCompareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AtomicCompareOp AtomicCompareOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value x, /*optional*/bool weak, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(x)>(x), std::forward<decltype(weak)>(weak), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicCompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, /*optional*/bool weak, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.addOperands(x);
|
|
if (weak) {
|
|
odsState.getOrAddProperties<Properties>().weak = ((weak) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
odsState.getOrAddProperties<Properties>().hint = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), hint);
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AtomicCompareOp AtomicCompareOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value x, /*optional*/bool weak, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(x)>(x), std::forward<decltype(weak)>(weak), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicCompareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AtomicCompareOp AtomicCompareOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value x, /*optional*/bool weak, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(x)>(x), std::forward<decltype(weak)>(weak), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicCompareOp::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);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<AtomicCompareOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
AtomicCompareOp AtomicCompareOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicCompareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AtomicCompareOp AtomicCompareOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void AtomicCompareOp::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&>(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);
|
|
}
|
|
|
|
AtomicCompareOp AtomicCompareOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicCompareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AtomicCompareOp AtomicCompareOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult AtomicCompareOp::verifyInvariantsImpl() {
|
|
auto tblgen_hint = getProperties().hint; (void)tblgen_hint;
|
|
auto tblgen_memory_order = getProperties().memory_order; (void)tblgen_memory_order;
|
|
auto tblgen_weak = getProperties().weak; (void)tblgen_weak;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_weak, "weak")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps3(*this, tblgen_hint, "hint")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps4(*this, tblgen_memory_order, "memory_order")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps1(*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_OpenMPOps1(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AtomicCompareOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult AtomicCompareOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::IntegerAttr hintAttr;
|
|
::mlir::omp::ClauseMemoryOrderKindAttr memory_orderAttr;
|
|
::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 hintClause = false;
|
|
bool memory_orderClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("hint"))) {
|
|
|
|
if (hintClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`hint` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
hintClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseSynchronizationHint(parser, hintAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (hintAttr)
|
|
result.getOrAddProperties<AtomicCompareOp::Properties>().hint = hintAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("memory_order"))) {
|
|
|
|
if (memory_orderClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`memory_order` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
memory_orderClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseClauseAttr(parser, memory_orderAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (memory_orderAttr)
|
|
result.getOrAddProperties<AtomicCompareOp::Properties>().memory_order = memory_orderAttr;
|
|
}
|
|
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::omp::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));
|
|
if (parser.resolveOperands(xOperands, xTypes, xOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AtomicCompareOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || ((getHintAttr() && getHintAttr() != ::mlir::OpBuilder((*this)->getContext()).getIntegerAttr(::mlir::OpBuilder((*this)->getContext()).getIntegerType(64), 0)))) {
|
|
_odsPrinter << ' ' << "hint";
|
|
_odsPrinter << "(";
|
|
printSynchronizationHint(_odsPrinter, *this, getHintAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getMemoryOrderAttr())) {
|
|
_odsPrinter << ' ' << "memory_order";
|
|
_odsPrinter << "(";
|
|
printClauseAttr(_odsPrinter, *this, getMemoryOrderAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getX();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
{
|
|
auto type = getX().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::omp::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;
|
|
elidedAttrs.push_back("hint");
|
|
elidedAttrs.push_back("memory_order");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getWeakAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("weak");
|
|
}
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getHintAttr();
|
|
if(attr && (attr == odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), 0)))
|
|
elidedAttrs.push_back("hint");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
void AtomicCompareOp::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::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::AtomicCompareOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::AtomicCompareOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::AtomicReadOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
AtomicReadOpGenericAdaptorBase::AtomicReadOpGenericAdaptorBase(AtomicReadOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::Type AtomicReadOpGenericAdaptorBase::getElementType() {
|
|
auto attr = getElementTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::mlir::IntegerAttr AtomicReadOpGenericAdaptorBase::getHintAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().hint);
|
|
if (!attr)
|
|
attr = ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(64), 0);
|
|
return attr;
|
|
}
|
|
|
|
uint64_t AtomicReadOpGenericAdaptorBase::getHint() {
|
|
auto attr = getHintAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(64), 0).getValue().getZExtValue();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseMemoryOrderKind> AtomicReadOpGenericAdaptorBase::getMemoryOrder() {
|
|
auto attr = getMemoryOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseMemoryOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // 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, "'omp.atomic.read' op requires attribute 'element_type'");
|
|
auto tblgen_hint = getProperties().hint; (void)tblgen_hint;
|
|
auto tblgen_memory_order = getProperties().memory_order; (void)tblgen_memory_order;
|
|
|
|
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, "'omp.atomic.read' op attribute 'element_type' failed to satisfy constraint: any type attribute");
|
|
|
|
if (tblgen_hint && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_hint))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_hint).getType().isSignlessInteger(64)))))
|
|
return emitError(loc, "'omp.atomic.read' op attribute 'hint' failed to satisfy constraint: 64-bit signless integer attribute");
|
|
|
|
if (tblgen_memory_order && !((::llvm::isa<::mlir::omp::ClauseMemoryOrderKindAttr>(tblgen_memory_order))))
|
|
return emitError(loc, "'omp.atomic.read' op attribute 'memory_order' failed to satisfy constraint: MemoryOrderKind Clause");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::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<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `element_type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.hint;
|
|
auto attr = dict.get("hint");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `hint` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.memory_order;
|
|
auto attr = dict.get("memory_order");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `memory_order` 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));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.hint;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("hint",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.memory_order;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("memory_order",
|
|
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()),
|
|
llvm::hash_value(prop.hint.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.memory_order.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> AtomicReadOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "element_type")
|
|
return prop.element_type;
|
|
|
|
if (name == "hint")
|
|
return prop.hint;
|
|
|
|
if (name == "memory_order")
|
|
return prop.memory_order;
|
|
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<std::remove_reference_t<decltype(prop.element_type)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "hint") {
|
|
prop.hint = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.hint)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "memory_order") {
|
|
prop.memory_order = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.memory_order)>>(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);
|
|
|
|
if (prop.hint) attrs.append("hint", prop.hint);
|
|
|
|
if (prop.memory_order) attrs.append("memory_order", prop.memory_order);
|
|
}
|
|
|
|
::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_OpenMPOps1(attr, "element_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getHintAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps3(attr, "hint", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMemoryOrderAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps4(attr, "memory_order", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AtomicReadOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.element_type)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.hint)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.memory_order)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AtomicReadOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.element_type);
|
|
|
|
writer.writeOptionalAttribute(prop.hint);
|
|
|
|
writer.writeOptionalAttribute(prop.memory_order);
|
|
}
|
|
|
|
::mlir::Type AtomicReadOp::getElementType() {
|
|
auto attr = getElementTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
uint64_t AtomicReadOp::getHint() {
|
|
auto attr = getHintAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), 0).getValue().getZExtValue();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseMemoryOrderKind> AtomicReadOp::getMemoryOrder() {
|
|
auto attr = getMemoryOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseMemoryOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
void AtomicReadOp::setElementType(::mlir::Type attrValue) {
|
|
getProperties().element_type = ::mlir::TypeAttr::get(attrValue);
|
|
}
|
|
|
|
void AtomicReadOp::setHint(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().hint;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void AtomicReadOp::setMemoryOrder(::std::optional<::mlir::omp::ClauseMemoryOrderKind> attrValue) {
|
|
auto &odsProp = getProperties().memory_order;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ClauseMemoryOrderKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void AtomicReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, ::mlir::Value v, ::mlir::TypeAttr element_type, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.addOperands(x);
|
|
odsState.addOperands(v);
|
|
odsState.getOrAddProperties<Properties>().element_type = element_type;
|
|
if (hint) {
|
|
odsState.getOrAddProperties<Properties>().hint = hint;
|
|
}
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
}
|
|
|
|
AtomicReadOp AtomicReadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value x, ::mlir::Value v, ::mlir::TypeAttr element_type, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(x)>(x), std::forward<decltype(v)>(v), std::forward<decltype(element_type)>(element_type), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicReadOp>(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::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(x)>(x), std::forward<decltype(v)>(v), std::forward<decltype(element_type)>(element_type), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value v, ::mlir::TypeAttr element_type, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.addOperands(x);
|
|
odsState.addOperands(v);
|
|
odsState.getOrAddProperties<Properties>().element_type = element_type;
|
|
if (hint) {
|
|
odsState.getOrAddProperties<Properties>().hint = hint;
|
|
}
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
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::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(x)>(x), std::forward<decltype(v)>(v), std::forward<decltype(element_type)>(element_type), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicReadOp>(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::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(x)>(x), std::forward<decltype(v)>(v), std::forward<decltype(element_type)>(element_type), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, ::mlir::Value v, ::mlir::Type element_type, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.addOperands(x);
|
|
odsState.addOperands(v);
|
|
odsState.getOrAddProperties<Properties>().element_type = ::mlir::TypeAttr::get(element_type);
|
|
odsState.getOrAddProperties<Properties>().hint = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), hint);
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
}
|
|
|
|
AtomicReadOp AtomicReadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value x, ::mlir::Value v, ::mlir::Type element_type, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(x)>(x), std::forward<decltype(v)>(v), std::forward<decltype(element_type)>(element_type), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicReadOp>(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*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(x)>(x), std::forward<decltype(v)>(v), std::forward<decltype(element_type)>(element_type), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value v, ::mlir::Type element_type, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.addOperands(x);
|
|
odsState.addOperands(v);
|
|
odsState.getOrAddProperties<Properties>().element_type = ::mlir::TypeAttr::get(element_type);
|
|
odsState.getOrAddProperties<Properties>().hint = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), hint);
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
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*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(x)>(x), std::forward<decltype(v)>(v), std::forward<decltype(element_type)>(element_type), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicReadOp>(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*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(x)>(x), std::forward<decltype(v)>(v), std::forward<decltype(element_type)>(element_type), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
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<AtomicReadOp::Properties>();
|
|
::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicReadOp>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(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&>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicReadOp>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(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'");
|
|
auto tblgen_hint = getProperties().hint; (void)tblgen_hint;
|
|
auto tblgen_memory_order = getProperties().memory_order; (void)tblgen_memory_order;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(*this, tblgen_element_type, "element_type")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps3(*this, tblgen_hint, "hint")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps4(*this, tblgen_memory_order, "memory_order")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps1(*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) {
|
|
::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::IntegerAttr hintAttr;
|
|
::mlir::omp::ClauseMemoryOrderKindAttr memory_orderAttr;
|
|
::mlir::Type vRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> vTypes(&vRawType, 1);
|
|
::mlir::Type xRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> xTypes(&xRawType, 1);
|
|
::mlir::TypeAttr element_typeAttr;
|
|
|
|
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();
|
|
bool hintClause = false;
|
|
bool memory_orderClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("hint"))) {
|
|
|
|
if (hintClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`hint` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
hintClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseSynchronizationHint(parser, hintAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (hintAttr)
|
|
result.getOrAddProperties<AtomicReadOp::Properties>().hint = hintAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("memory_order"))) {
|
|
|
|
if (memory_orderClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`memory_order` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
memory_orderClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseClauseAttr(parser, memory_orderAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (memory_orderAttr)
|
|
result.getOrAddProperties<AtomicReadOp::Properties>().memory_order = memory_orderAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
::mlir::omp::PointerLikeType type;
|
|
if (parser.parseCustomTypeWithFallback(type))
|
|
return ::mlir::failure();
|
|
vRawType = type;
|
|
}
|
|
if (parser.parseComma())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
::mlir::omp::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<AtomicReadOp::Properties>().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();
|
|
}
|
|
if (parser.resolveOperands(xOperands, xTypes, xOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(vOperands, vTypes, vOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AtomicReadOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getV();
|
|
_odsPrinter << ' ' << "=";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getX();
|
|
if (false || ((getHintAttr() && getHintAttr() != ::mlir::OpBuilder((*this)->getContext()).getIntegerAttr(::mlir::OpBuilder((*this)->getContext()).getIntegerType(64), 0)))) {
|
|
_odsPrinter << ' ' << "hint";
|
|
_odsPrinter << "(";
|
|
printSynchronizationHint(_odsPrinter, *this, getHintAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getMemoryOrderAttr())) {
|
|
_odsPrinter << ' ' << "memory_order";
|
|
_odsPrinter << "(";
|
|
printClauseAttr(_odsPrinter, *this, getMemoryOrderAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
{
|
|
auto type = getV().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::omp::PointerLikeType>(type))
|
|
_odsPrinter.printStrippedAttrOrType(validType);
|
|
else
|
|
_odsPrinter << type;
|
|
}
|
|
_odsPrinter << ",";
|
|
_odsPrinter << ' ';
|
|
{
|
|
auto type = getX().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::omp::PointerLikeType>(type))
|
|
_odsPrinter.printStrippedAttrOrType(validType);
|
|
else
|
|
_odsPrinter << type;
|
|
}
|
|
_odsPrinter << ",";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printAttributeWithoutType(getElementTypeAttr());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("hint");
|
|
elidedAttrs.push_back("memory_order");
|
|
elidedAttrs.push_back("element_type");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getHintAttr();
|
|
if(attr && (attr == odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), 0)))
|
|
elidedAttrs.push_back("hint");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::AtomicReadOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::AtomicReadOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::AtomicUpdateOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
AtomicUpdateOpGenericAdaptorBase::AtomicUpdateOpGenericAdaptorBase(AtomicUpdateOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::std::optional<::mlir::omp::AtomicControlAttr> AtomicUpdateOpGenericAdaptorBase::getAtomicControl() {
|
|
auto attr = getAtomicControlAttr();
|
|
return attr ? ::std::optional<::mlir::omp::AtomicControlAttr>(::llvm::cast<::mlir::omp::AtomicControlAttr>(attr)) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::IntegerAttr AtomicUpdateOpGenericAdaptorBase::getHintAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().hint);
|
|
if (!attr)
|
|
attr = ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(64), 0);
|
|
return attr;
|
|
}
|
|
|
|
uint64_t AtomicUpdateOpGenericAdaptorBase::getHint() {
|
|
auto attr = getHintAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(64), 0).getValue().getZExtValue();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseMemoryOrderKind> AtomicUpdateOpGenericAdaptorBase::getMemoryOrder() {
|
|
auto attr = getMemoryOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseMemoryOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
AtomicUpdateOpAdaptor::AtomicUpdateOpAdaptor(AtomicUpdateOp op) : AtomicUpdateOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult AtomicUpdateOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_atomic_control = getProperties().atomic_control; (void)tblgen_atomic_control;
|
|
auto tblgen_hint = getProperties().hint; (void)tblgen_hint;
|
|
auto tblgen_memory_order = getProperties().memory_order; (void)tblgen_memory_order;
|
|
|
|
if (tblgen_atomic_control && !((::llvm::isa<::mlir::omp::AtomicControlAttr>(tblgen_atomic_control))))
|
|
return emitError(loc, "'omp.atomic.update' op attribute 'atomic_control' failed to satisfy constraint: ");
|
|
|
|
if (tblgen_hint && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_hint))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_hint).getType().isSignlessInteger(64)))))
|
|
return emitError(loc, "'omp.atomic.update' op attribute 'hint' failed to satisfy constraint: 64-bit signless integer attribute");
|
|
|
|
if (tblgen_memory_order && !((::llvm::isa<::mlir::omp::ClauseMemoryOrderKindAttr>(tblgen_memory_order))))
|
|
return emitError(loc, "'omp.atomic.update' op attribute 'memory_order' failed to satisfy constraint: MemoryOrderKind Clause");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::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();
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.atomic_control;
|
|
auto attr = dict.get("atomic_control");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `atomic_control` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.hint;
|
|
auto attr = dict.get("hint");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `hint` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.memory_order;
|
|
auto attr = dict.get("memory_order");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `memory_order` in property conversion: " << attr;
|
|
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};
|
|
|
|
{
|
|
const auto &propStorage = prop.atomic_control;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("atomic_control",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.hint;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("hint",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.memory_order;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("memory_order",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code AtomicUpdateOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.atomic_control.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.hint.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.memory_order.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> AtomicUpdateOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "atomic_control")
|
|
return prop.atomic_control;
|
|
|
|
if (name == "hint")
|
|
return prop.hint;
|
|
|
|
if (name == "memory_order")
|
|
return prop.memory_order;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void AtomicUpdateOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "atomic_control") {
|
|
prop.atomic_control = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.atomic_control)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "hint") {
|
|
prop.hint = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.hint)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "memory_order") {
|
|
prop.memory_order = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.memory_order)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void AtomicUpdateOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.atomic_control) attrs.append("atomic_control", prop.atomic_control);
|
|
|
|
if (prop.hint) attrs.append("hint", prop.hint);
|
|
|
|
if (prop.memory_order) attrs.append("memory_order", prop.memory_order);
|
|
}
|
|
|
|
::llvm::LogicalResult AtomicUpdateOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAtomicControlAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps6(attr, "atomic_control", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getHintAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps3(attr, "hint", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMemoryOrderAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps4(attr, "memory_order", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AtomicUpdateOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.atomic_control)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.hint)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.memory_order)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AtomicUpdateOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.atomic_control);
|
|
|
|
writer.writeOptionalAttribute(prop.hint);
|
|
|
|
writer.writeOptionalAttribute(prop.memory_order);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::AtomicControlAttr> AtomicUpdateOp::getAtomicControl() {
|
|
auto attr = getAtomicControlAttr();
|
|
return attr ? ::std::optional<::mlir::omp::AtomicControlAttr>(::llvm::cast<::mlir::omp::AtomicControlAttr>(attr)) : (::std::nullopt);
|
|
}
|
|
|
|
uint64_t AtomicUpdateOp::getHint() {
|
|
auto attr = getHintAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), 0).getValue().getZExtValue();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseMemoryOrderKind> AtomicUpdateOp::getMemoryOrder() {
|
|
auto attr = getMemoryOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseMemoryOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
void AtomicUpdateOp::setHint(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().hint;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void AtomicUpdateOp::setMemoryOrder(::std::optional<::mlir::omp::ClauseMemoryOrderKind> attrValue) {
|
|
auto &odsProp = getProperties().memory_order;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ClauseMemoryOrderKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void AtomicUpdateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, /*optional*/::mlir::omp::AtomicControlAttr atomic_control, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.addOperands(x);
|
|
if (atomic_control) {
|
|
odsState.getOrAddProperties<Properties>().atomic_control = atomic_control;
|
|
}
|
|
if (hint) {
|
|
odsState.getOrAddProperties<Properties>().hint = hint;
|
|
}
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
AtomicUpdateOp AtomicUpdateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value x, /*optional*/::mlir::omp::AtomicControlAttr atomic_control, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(x)>(x), std::forward<decltype(atomic_control)>(atomic_control), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicUpdateOp>(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::omp::AtomicControlAttr atomic_control, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(x)>(x), std::forward<decltype(atomic_control)>(atomic_control), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicUpdateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, /*optional*/::mlir::omp::AtomicControlAttr atomic_control, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.addOperands(x);
|
|
if (atomic_control) {
|
|
odsState.getOrAddProperties<Properties>().atomic_control = atomic_control;
|
|
}
|
|
if (hint) {
|
|
odsState.getOrAddProperties<Properties>().hint = hint;
|
|
}
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
(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::omp::AtomicControlAttr atomic_control, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(x)>(x), std::forward<decltype(atomic_control)>(atomic_control), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicUpdateOp>(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::omp::AtomicControlAttr atomic_control, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(x)>(x), std::forward<decltype(atomic_control)>(atomic_control), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicUpdateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, /*optional*/::mlir::omp::AtomicControlAttr atomic_control, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.addOperands(x);
|
|
if (atomic_control) {
|
|
odsState.getOrAddProperties<Properties>().atomic_control = atomic_control;
|
|
}
|
|
odsState.getOrAddProperties<Properties>().hint = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), hint);
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
AtomicUpdateOp AtomicUpdateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value x, /*optional*/::mlir::omp::AtomicControlAttr atomic_control, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(x)>(x), std::forward<decltype(atomic_control)>(atomic_control), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicUpdateOp>(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::omp::AtomicControlAttr atomic_control, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(x)>(x), std::forward<decltype(atomic_control)>(atomic_control), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicUpdateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, /*optional*/::mlir::omp::AtomicControlAttr atomic_control, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.addOperands(x);
|
|
if (atomic_control) {
|
|
odsState.getOrAddProperties<Properties>().atomic_control = atomic_control;
|
|
}
|
|
odsState.getOrAddProperties<Properties>().hint = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), hint);
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
(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::omp::AtomicControlAttr atomic_control, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(x)>(x), std::forward<decltype(atomic_control)>(atomic_control), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicUpdateOp>(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::omp::AtomicControlAttr atomic_control, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(x)>(x), std::forward<decltype(atomic_control)>(atomic_control), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
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);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<AtomicUpdateOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicUpdateOp>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(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&>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicUpdateOp>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult AtomicUpdateOp::verifyInvariantsImpl() {
|
|
auto tblgen_atomic_control = getProperties().atomic_control; (void)tblgen_atomic_control;
|
|
auto tblgen_hint = getProperties().hint; (void)tblgen_hint;
|
|
auto tblgen_memory_order = getProperties().memory_order; (void)tblgen_memory_order;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps6(*this, tblgen_atomic_control, "atomic_control")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps3(*this, tblgen_hint, "hint")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps4(*this, tblgen_memory_order, "memory_order")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps1(*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_OpenMPOps1(*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) {
|
|
::mlir::IntegerAttr hintAttr;
|
|
::mlir::omp::ClauseMemoryOrderKindAttr memory_orderAttr;
|
|
::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 hintClause = false;
|
|
bool memory_orderClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("hint"))) {
|
|
|
|
if (hintClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`hint` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
hintClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseSynchronizationHint(parser, hintAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (hintAttr)
|
|
result.getOrAddProperties<AtomicUpdateOp::Properties>().hint = hintAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("memory_order"))) {
|
|
|
|
if (memory_orderClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`memory_order` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
memory_orderClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseClauseAttr(parser, memory_orderAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (memory_orderAttr)
|
|
result.getOrAddProperties<AtomicUpdateOp::Properties>().memory_order = memory_orderAttr;
|
|
}
|
|
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::omp::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));
|
|
if (parser.resolveOperands(xOperands, xTypes, xOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AtomicUpdateOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || ((getHintAttr() && getHintAttr() != ::mlir::OpBuilder((*this)->getContext()).getIntegerAttr(::mlir::OpBuilder((*this)->getContext()).getIntegerType(64), 0)))) {
|
|
_odsPrinter << ' ' << "hint";
|
|
_odsPrinter << "(";
|
|
printSynchronizationHint(_odsPrinter, *this, getHintAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getMemoryOrderAttr())) {
|
|
_odsPrinter << ' ' << "memory_order";
|
|
_odsPrinter << "(";
|
|
printClauseAttr(_odsPrinter, *this, getMemoryOrderAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getX();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
{
|
|
auto type = getX().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::omp::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;
|
|
elidedAttrs.push_back("hint");
|
|
elidedAttrs.push_back("memory_order");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getHintAttr();
|
|
if(attr && (attr == odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), 0)))
|
|
elidedAttrs.push_back("hint");
|
|
}
|
|
_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::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::AtomicUpdateOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::AtomicUpdateOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::AtomicWriteOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
AtomicWriteOpGenericAdaptorBase::AtomicWriteOpGenericAdaptorBase(AtomicWriteOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::IntegerAttr AtomicWriteOpGenericAdaptorBase::getHintAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().hint);
|
|
if (!attr)
|
|
attr = ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(64), 0);
|
|
return attr;
|
|
}
|
|
|
|
uint64_t AtomicWriteOpGenericAdaptorBase::getHint() {
|
|
auto attr = getHintAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(64), 0).getValue().getZExtValue();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseMemoryOrderKind> AtomicWriteOpGenericAdaptorBase::getMemoryOrder() {
|
|
auto attr = getMemoryOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseMemoryOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
AtomicWriteOpAdaptor::AtomicWriteOpAdaptor(AtomicWriteOp op) : AtomicWriteOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult AtomicWriteOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_hint = getProperties().hint; (void)tblgen_hint;
|
|
auto tblgen_memory_order = getProperties().memory_order; (void)tblgen_memory_order;
|
|
|
|
if (tblgen_hint && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_hint))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_hint).getType().isSignlessInteger(64)))))
|
|
return emitError(loc, "'omp.atomic.write' op attribute 'hint' failed to satisfy constraint: 64-bit signless integer attribute");
|
|
|
|
if (tblgen_memory_order && !((::llvm::isa<::mlir::omp::ClauseMemoryOrderKindAttr>(tblgen_memory_order))))
|
|
return emitError(loc, "'omp.atomic.write' op attribute 'memory_order' failed to satisfy constraint: MemoryOrderKind Clause");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::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();
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.hint;
|
|
auto attr = dict.get("hint");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `hint` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.memory_order;
|
|
auto attr = dict.get("memory_order");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `memory_order` in property conversion: " << attr;
|
|
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};
|
|
|
|
{
|
|
const auto &propStorage = prop.hint;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("hint",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.memory_order;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("memory_order",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code AtomicWriteOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.hint.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.memory_order.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> AtomicWriteOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "hint")
|
|
return prop.hint;
|
|
|
|
if (name == "memory_order")
|
|
return prop.memory_order;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void AtomicWriteOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "hint") {
|
|
prop.hint = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.hint)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "memory_order") {
|
|
prop.memory_order = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.memory_order)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void AtomicWriteOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.hint) attrs.append("hint", prop.hint);
|
|
|
|
if (prop.memory_order) attrs.append("memory_order", prop.memory_order);
|
|
}
|
|
|
|
::llvm::LogicalResult AtomicWriteOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getHintAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps3(attr, "hint", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMemoryOrderAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps4(attr, "memory_order", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AtomicWriteOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.hint)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.memory_order)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AtomicWriteOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.hint);
|
|
|
|
writer.writeOptionalAttribute(prop.memory_order);
|
|
}
|
|
|
|
uint64_t AtomicWriteOp::getHint() {
|
|
auto attr = getHintAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), 0).getValue().getZExtValue();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseMemoryOrderKind> AtomicWriteOp::getMemoryOrder() {
|
|
auto attr = getMemoryOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseMemoryOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
void AtomicWriteOp::setHint(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().hint;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void AtomicWriteOp::setMemoryOrder(::std::optional<::mlir::omp::ClauseMemoryOrderKind> attrValue) {
|
|
auto &odsProp = getProperties().memory_order;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ClauseMemoryOrderKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void AtomicWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, ::mlir::Value expr, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.addOperands(x);
|
|
odsState.addOperands(expr);
|
|
if (hint) {
|
|
odsState.getOrAddProperties<Properties>().hint = hint;
|
|
}
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
}
|
|
|
|
AtomicWriteOp AtomicWriteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value x, ::mlir::Value expr, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(x)>(x), std::forward<decltype(expr)>(expr), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicWriteOp>(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::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(x)>(x), std::forward<decltype(expr)>(expr), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value expr, /*optional*/::mlir::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.addOperands(x);
|
|
odsState.addOperands(expr);
|
|
if (hint) {
|
|
odsState.getOrAddProperties<Properties>().hint = hint;
|
|
}
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
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::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(x)>(x), std::forward<decltype(expr)>(expr), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicWriteOp>(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::IntegerAttr hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(x)>(x), std::forward<decltype(expr)>(expr), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, ::mlir::Value expr, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.addOperands(x);
|
|
odsState.addOperands(expr);
|
|
odsState.getOrAddProperties<Properties>().hint = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), hint);
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
}
|
|
|
|
AtomicWriteOp AtomicWriteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value x, ::mlir::Value expr, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(x)>(x), std::forward<decltype(expr)>(expr), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicWriteOp>(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*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(x)>(x), std::forward<decltype(expr)>(expr), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
void AtomicWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value expr, /*optional*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
odsState.addOperands(x);
|
|
odsState.addOperands(expr);
|
|
odsState.getOrAddProperties<Properties>().hint = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), hint);
|
|
if (memory_order) {
|
|
odsState.getOrAddProperties<Properties>().memory_order = memory_order;
|
|
}
|
|
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*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(x)>(x), std::forward<decltype(expr)>(expr), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicWriteOp>(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*/uint64_t hint, /*optional*/::mlir::omp::ClauseMemoryOrderKindAttr memory_order) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(x)>(x), std::forward<decltype(expr)>(expr), std::forward<decltype(hint)>(hint), std::forward<decltype(memory_order)>(memory_order));
|
|
}
|
|
|
|
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);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<AtomicWriteOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicWriteOp>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(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&>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<AtomicWriteOp>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult AtomicWriteOp::verifyInvariantsImpl() {
|
|
auto tblgen_hint = getProperties().hint; (void)tblgen_hint;
|
|
auto tblgen_memory_order = getProperties().memory_order; (void)tblgen_memory_order;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps3(*this, tblgen_hint, "hint")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps4(*this, tblgen_memory_order, "memory_order")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps7(*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) {
|
|
::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::IntegerAttr hintAttr;
|
|
::mlir::omp::ClauseMemoryOrderKindAttr memory_orderAttr;
|
|
::mlir::Type xRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> xTypes(&xRawType, 1);
|
|
::mlir::Type exprRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> exprTypes(&exprRawType, 1);
|
|
|
|
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();
|
|
bool hintClause = false;
|
|
bool memory_orderClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("hint"))) {
|
|
|
|
if (hintClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`hint` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
hintClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseSynchronizationHint(parser, hintAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (hintAttr)
|
|
result.getOrAddProperties<AtomicWriteOp::Properties>().hint = hintAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("memory_order"))) {
|
|
|
|
if (memory_orderClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`memory_order` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
memory_orderClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseClauseAttr(parser, memory_orderAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (memory_orderAttr)
|
|
result.getOrAddProperties<AtomicWriteOp::Properties>().memory_order = memory_orderAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
::mlir::omp::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();
|
|
}
|
|
if (parser.resolveOperands(xOperands, xTypes, xOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(exprOperands, exprTypes, exprOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AtomicWriteOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getX();
|
|
_odsPrinter << ' ' << "=";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getExpr();
|
|
if (false || ((getHintAttr() && getHintAttr() != ::mlir::OpBuilder((*this)->getContext()).getIntegerAttr(::mlir::OpBuilder((*this)->getContext()).getIntegerType(64), 0)))) {
|
|
_odsPrinter << ' ' << "hint";
|
|
_odsPrinter << "(";
|
|
printSynchronizationHint(_odsPrinter, *this, getHintAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getMemoryOrderAttr())) {
|
|
_odsPrinter << ' ' << "memory_order";
|
|
_odsPrinter << "(";
|
|
printClauseAttr(_odsPrinter, *this, getMemoryOrderAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
{
|
|
auto type = getX().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::omp::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;
|
|
elidedAttrs.push_back("hint");
|
|
elidedAttrs.push_back("memory_order");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getHintAttr();
|
|
if(attr && (attr == odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), 0)))
|
|
elidedAttrs.push_back("hint");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::AtomicWriteOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::AtomicWriteOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::BarrierOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
BarrierOpGenericAdaptorBase::BarrierOpGenericAdaptorBase(BarrierOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
BarrierOpAdaptor::BarrierOpAdaptor(BarrierOp op) : BarrierOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult BarrierOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult BarrierOp::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 BarrierOp::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 BarrierOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> BarrierOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void BarrierOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void BarrierOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult BarrierOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void BarrierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) {
|
|
}
|
|
|
|
BarrierOp BarrierOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__);
|
|
auto __res__ = ::llvm::dyn_cast<BarrierOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BarrierOp BarrierOp::create(::mlir::ImplicitLocOpBuilder &builder) {
|
|
return create(builder, builder.getLoc());
|
|
}
|
|
|
|
void BarrierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) {
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
BarrierOp BarrierOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes));
|
|
auto __res__ = ::llvm::dyn_cast<BarrierOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BarrierOp BarrierOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes));
|
|
}
|
|
|
|
void BarrierOp::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);
|
|
}
|
|
|
|
BarrierOp BarrierOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<BarrierOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BarrierOp BarrierOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void BarrierOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
BarrierOp BarrierOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<BarrierOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BarrierOp BarrierOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult BarrierOp::verifyInvariantsImpl() {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult BarrierOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult BarrierOp::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 BarrierOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::BarrierOp)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::CancelOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
CancelOpGenericAdaptorBase::CancelOpGenericAdaptorBase(CancelOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> CancelOpGenericAdaptorBase::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::omp::ClauseCancellationConstructType CancelOpGenericAdaptorBase::getCancelDirective() {
|
|
auto attr = getCancelDirectiveAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
CancelOpAdaptor::CancelOpAdaptor(CancelOp op) : CancelOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult CancelOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_cancel_directive = getProperties().cancel_directive; (void)tblgen_cancel_directive;
|
|
if (!tblgen_cancel_directive) return emitError(loc, "'omp.cancel' op requires attribute 'cancel_directive'");
|
|
|
|
if (tblgen_cancel_directive && !((::llvm::isa<::mlir::omp::ClauseCancellationConstructTypeAttr>(tblgen_cancel_directive))))
|
|
return emitError(loc, "'omp.cancel' op attribute 'cancel_directive' failed to satisfy constraint: CancellationConstructType Clause");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> CancelOp::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 CancelOp::getIfExprMutable() {
|
|
auto range = getODSOperandIndexAndLength(0);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
|
|
return mutableRange;
|
|
}
|
|
|
|
::llvm::LogicalResult CancelOp::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.cancel_directive;
|
|
auto attr = dict.get("cancel_directive");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `cancel_directive` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute CancelOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.cancel_directive;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("cancel_directive",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code CancelOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.cancel_directive.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> CancelOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "cancel_directive")
|
|
return prop.cancel_directive;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void CancelOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "cancel_directive") {
|
|
prop.cancel_directive = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.cancel_directive)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void CancelOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.cancel_directive) attrs.append("cancel_directive", prop.cancel_directive);
|
|
}
|
|
|
|
::llvm::LogicalResult CancelOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getCancelDirectiveAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps7(attr, "cancel_directive", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CancelOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.cancel_directive)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CancelOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.cancel_directive);
|
|
}
|
|
|
|
::mlir::omp::ClauseCancellationConstructType CancelOp::getCancelDirective() {
|
|
auto attr = getCancelDirectiveAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void CancelOp::setCancelDirective(::mlir::omp::ClauseCancellationConstructType attrValue) {
|
|
getProperties().cancel_directive = ::mlir::omp::ClauseCancellationConstructTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
CancelOp CancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const CancelOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<CancelOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CancelOp CancelOp::create(::mlir::ImplicitLocOpBuilder &builder, const CancelOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void CancelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::omp::ClauseCancellationConstructTypeAttr cancel_directive, /*optional*/::mlir::Value if_expr) {
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.getOrAddProperties<Properties>().cancel_directive = cancel_directive;
|
|
}
|
|
|
|
CancelOp CancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::omp::ClauseCancellationConstructTypeAttr cancel_directive, /*optional*/::mlir::Value if_expr) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(cancel_directive)>(cancel_directive), std::forward<decltype(if_expr)>(if_expr));
|
|
auto __res__ = ::llvm::dyn_cast<CancelOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CancelOp CancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::omp::ClauseCancellationConstructTypeAttr cancel_directive, /*optional*/::mlir::Value if_expr) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(cancel_directive)>(cancel_directive), std::forward<decltype(if_expr)>(if_expr));
|
|
}
|
|
|
|
void CancelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::omp::ClauseCancellationConstructTypeAttr cancel_directive, /*optional*/::mlir::Value if_expr) {
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.getOrAddProperties<Properties>().cancel_directive = cancel_directive;
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CancelOp CancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::omp::ClauseCancellationConstructTypeAttr cancel_directive, /*optional*/::mlir::Value if_expr) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(cancel_directive)>(cancel_directive), std::forward<decltype(if_expr)>(if_expr));
|
|
auto __res__ = ::llvm::dyn_cast<CancelOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CancelOp CancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::omp::ClauseCancellationConstructTypeAttr cancel_directive, /*optional*/::mlir::Value if_expr) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(cancel_directive)>(cancel_directive), std::forward<decltype(if_expr)>(if_expr));
|
|
}
|
|
|
|
void CancelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::omp::ClauseCancellationConstructType cancel_directive, /*optional*/::mlir::Value if_expr) {
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.getOrAddProperties<Properties>().cancel_directive = ::mlir::omp::ClauseCancellationConstructTypeAttr::get(odsBuilder.getContext(), cancel_directive);
|
|
}
|
|
|
|
CancelOp CancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::omp::ClauseCancellationConstructType cancel_directive, /*optional*/::mlir::Value if_expr) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(cancel_directive)>(cancel_directive), std::forward<decltype(if_expr)>(if_expr));
|
|
auto __res__ = ::llvm::dyn_cast<CancelOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CancelOp CancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::omp::ClauseCancellationConstructType cancel_directive, /*optional*/::mlir::Value if_expr) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(cancel_directive)>(cancel_directive), std::forward<decltype(if_expr)>(if_expr));
|
|
}
|
|
|
|
void CancelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::omp::ClauseCancellationConstructType cancel_directive, /*optional*/::mlir::Value if_expr) {
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.getOrAddProperties<Properties>().cancel_directive = ::mlir::omp::ClauseCancellationConstructTypeAttr::get(odsBuilder.getContext(), cancel_directive);
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CancelOp CancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::omp::ClauseCancellationConstructType cancel_directive, /*optional*/::mlir::Value if_expr) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(cancel_directive)>(cancel_directive), std::forward<decltype(if_expr)>(if_expr));
|
|
auto __res__ = ::llvm::dyn_cast<CancelOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CancelOp CancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::omp::ClauseCancellationConstructType cancel_directive, /*optional*/::mlir::Value if_expr) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(cancel_directive)>(cancel_directive), std::forward<decltype(if_expr)>(if_expr));
|
|
}
|
|
|
|
void CancelOp::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<CancelOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
CancelOp CancelOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<CancelOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CancelOp CancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void CancelOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CancelOp CancelOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<CancelOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CancelOp CancelOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult CancelOp::verifyInvariantsImpl() {
|
|
auto tblgen_cancel_directive = getProperties().cancel_directive; (void)tblgen_cancel_directive;
|
|
if (!tblgen_cancel_directive) return emitOpError("requires attribute 'cancel_directive'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps7(*this, tblgen_cancel_directive, "cancel_directive")))
|
|
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_OpenMPOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CancelOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult CancelOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::omp::ClauseCancellationConstructTypeAttr cancel_directiveAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> if_exprOperands;
|
|
::llvm::SMLoc if_exprOperandsLoc;
|
|
(void)if_exprOperandsLoc;
|
|
if (parser.parseKeyword("cancellation_construct_type"))
|
|
return ::mlir::failure();
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseClauseAttr(parser, cancel_directiveAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
result.getOrAddProperties<CancelOp::Properties>().cancel_directive = cancel_directiveAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
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();
|
|
|
|
{
|
|
if_exprOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
if_exprOperands.push_back(operand);
|
|
}
|
|
}
|
|
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();
|
|
}
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1);
|
|
if (!if_exprOperands.empty()) {
|
|
if (parser.resolveOperands(if_exprOperands, odsBuildableType0, if_exprOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CancelOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ' << "cancellation_construct_type";
|
|
_odsPrinter << "(";
|
|
printClauseAttr(_odsPrinter, *this, getCancelDirectiveAttr());
|
|
_odsPrinter << ")";
|
|
if (false || getIfExpr()) {
|
|
_odsPrinter << ' ' << "if";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getIfExpr())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ")";
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("cancel_directive");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::CancelOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::CancelOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::CancellationPointOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
CancellationPointOpGenericAdaptorBase::CancellationPointOpGenericAdaptorBase(CancellationPointOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::omp::ClauseCancellationConstructType CancellationPointOpGenericAdaptorBase::getCancelDirective() {
|
|
auto attr = getCancelDirectiveAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
CancellationPointOpAdaptor::CancellationPointOpAdaptor(CancellationPointOp op) : CancellationPointOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult CancellationPointOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_cancel_directive = getProperties().cancel_directive; (void)tblgen_cancel_directive;
|
|
if (!tblgen_cancel_directive) return emitError(loc, "'omp.cancellation_point' op requires attribute 'cancel_directive'");
|
|
|
|
if (tblgen_cancel_directive && !((::llvm::isa<::mlir::omp::ClauseCancellationConstructTypeAttr>(tblgen_cancel_directive))))
|
|
return emitError(loc, "'omp.cancellation_point' op attribute 'cancel_directive' failed to satisfy constraint: CancellationConstructType Clause");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CancellationPointOp::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.cancel_directive;
|
|
auto attr = dict.get("cancel_directive");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `cancel_directive` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute CancellationPointOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.cancel_directive;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("cancel_directive",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code CancellationPointOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.cancel_directive.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> CancellationPointOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "cancel_directive")
|
|
return prop.cancel_directive;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void CancellationPointOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "cancel_directive") {
|
|
prop.cancel_directive = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.cancel_directive)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void CancellationPointOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.cancel_directive) attrs.append("cancel_directive", prop.cancel_directive);
|
|
}
|
|
|
|
::llvm::LogicalResult CancellationPointOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getCancelDirectiveAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps7(attr, "cancel_directive", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CancellationPointOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.cancel_directive)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CancellationPointOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.cancel_directive);
|
|
}
|
|
|
|
::mlir::omp::ClauseCancellationConstructType CancellationPointOp::getCancelDirective() {
|
|
auto attr = getCancelDirectiveAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void CancellationPointOp::setCancelDirective(::mlir::omp::ClauseCancellationConstructType attrValue) {
|
|
getProperties().cancel_directive = ::mlir::omp::ClauseCancellationConstructTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
CancellationPointOp CancellationPointOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const CancellationPointOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<CancellationPointOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CancellationPointOp CancellationPointOp::create(::mlir::ImplicitLocOpBuilder &builder, const CancellationPointOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void CancellationPointOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::omp::ClauseCancellationConstructTypeAttr cancel_directive) {
|
|
odsState.getOrAddProperties<Properties>().cancel_directive = cancel_directive;
|
|
}
|
|
|
|
CancellationPointOp CancellationPointOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::omp::ClauseCancellationConstructTypeAttr cancel_directive) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(cancel_directive)>(cancel_directive));
|
|
auto __res__ = ::llvm::dyn_cast<CancellationPointOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CancellationPointOp CancellationPointOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::omp::ClauseCancellationConstructTypeAttr cancel_directive) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(cancel_directive)>(cancel_directive));
|
|
}
|
|
|
|
void CancellationPointOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::omp::ClauseCancellationConstructTypeAttr cancel_directive) {
|
|
odsState.getOrAddProperties<Properties>().cancel_directive = cancel_directive;
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CancellationPointOp CancellationPointOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::omp::ClauseCancellationConstructTypeAttr cancel_directive) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(cancel_directive)>(cancel_directive));
|
|
auto __res__ = ::llvm::dyn_cast<CancellationPointOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CancellationPointOp CancellationPointOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::omp::ClauseCancellationConstructTypeAttr cancel_directive) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(cancel_directive)>(cancel_directive));
|
|
}
|
|
|
|
void CancellationPointOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::omp::ClauseCancellationConstructType cancel_directive) {
|
|
odsState.getOrAddProperties<Properties>().cancel_directive = ::mlir::omp::ClauseCancellationConstructTypeAttr::get(odsBuilder.getContext(), cancel_directive);
|
|
}
|
|
|
|
CancellationPointOp CancellationPointOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::omp::ClauseCancellationConstructType cancel_directive) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(cancel_directive)>(cancel_directive));
|
|
auto __res__ = ::llvm::dyn_cast<CancellationPointOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CancellationPointOp CancellationPointOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::omp::ClauseCancellationConstructType cancel_directive) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(cancel_directive)>(cancel_directive));
|
|
}
|
|
|
|
void CancellationPointOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::omp::ClauseCancellationConstructType cancel_directive) {
|
|
odsState.getOrAddProperties<Properties>().cancel_directive = ::mlir::omp::ClauseCancellationConstructTypeAttr::get(odsBuilder.getContext(), cancel_directive);
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CancellationPointOp CancellationPointOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::omp::ClauseCancellationConstructType cancel_directive) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(cancel_directive)>(cancel_directive));
|
|
auto __res__ = ::llvm::dyn_cast<CancellationPointOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CancellationPointOp CancellationPointOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::omp::ClauseCancellationConstructType cancel_directive) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(cancel_directive)>(cancel_directive));
|
|
}
|
|
|
|
void CancellationPointOp::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<CancellationPointOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
CancellationPointOp CancellationPointOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<CancellationPointOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CancellationPointOp CancellationPointOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void CancellationPointOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CancellationPointOp CancellationPointOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<CancellationPointOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CancellationPointOp CancellationPointOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult CancellationPointOp::verifyInvariantsImpl() {
|
|
auto tblgen_cancel_directive = getProperties().cancel_directive; (void)tblgen_cancel_directive;
|
|
if (!tblgen_cancel_directive) return emitOpError("requires attribute 'cancel_directive'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps7(*this, tblgen_cancel_directive, "cancel_directive")))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CancellationPointOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult CancellationPointOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::omp::ClauseCancellationConstructTypeAttr cancel_directiveAttr;
|
|
if (parser.parseKeyword("cancellation_construct_type"))
|
|
return ::mlir::failure();
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseClauseAttr(parser, cancel_directiveAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
result.getOrAddProperties<CancellationPointOp::Properties>().cancel_directive = cancel_directiveAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
|
|
return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
|
|
})))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CancellationPointOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ' << "cancellation_construct_type";
|
|
_odsPrinter << "(";
|
|
printClauseAttr(_odsPrinter, *this, getCancelDirectiveAttr());
|
|
_odsPrinter << ")";
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("cancel_directive");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::CancellationPointOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::CancellationPointOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::CanonicalLoopOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
CanonicalLoopOpGenericAdaptorBase::CanonicalLoopOpGenericAdaptorBase(CanonicalLoopOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> CanonicalLoopOpGenericAdaptorBase::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
|
|
CanonicalLoopOpAdaptor::CanonicalLoopOpAdaptor(CanonicalLoopOp op) : CanonicalLoopOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult CanonicalLoopOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> CanonicalLoopOp::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 CanonicalLoopOp::getCliMutable() {
|
|
auto range = getODSOperandIndexAndLength(1);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
|
|
return mutableRange;
|
|
}
|
|
|
|
::llvm::LogicalResult CanonicalLoopOp::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 CanonicalLoopOp::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 CanonicalLoopOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> CanonicalLoopOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void CanonicalLoopOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void CanonicalLoopOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult CanonicalLoopOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
CanonicalLoopOp CanonicalLoopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value tripCount) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(tripCount)>(tripCount));
|
|
auto __res__ = ::llvm::dyn_cast<CanonicalLoopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CanonicalLoopOp CanonicalLoopOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value tripCount) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(tripCount)>(tripCount));
|
|
}
|
|
|
|
CanonicalLoopOp CanonicalLoopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value tripCount, ::mlir::Value cli) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(tripCount)>(tripCount), std::forward<decltype(cli)>(cli));
|
|
auto __res__ = ::llvm::dyn_cast<CanonicalLoopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CanonicalLoopOp CanonicalLoopOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value tripCount, ::mlir::Value cli) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(tripCount)>(tripCount), std::forward<decltype(cli)>(cli));
|
|
}
|
|
|
|
void CanonicalLoopOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tripCount, /*optional*/::mlir::Value cli) {
|
|
odsState.addOperands(tripCount);
|
|
if (cli)
|
|
odsState.addOperands(cli);
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CanonicalLoopOp CanonicalLoopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value tripCount, /*optional*/::mlir::Value cli) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(tripCount)>(tripCount), std::forward<decltype(cli)>(cli));
|
|
auto __res__ = ::llvm::dyn_cast<CanonicalLoopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CanonicalLoopOp CanonicalLoopOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value tripCount, /*optional*/::mlir::Value cli) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(tripCount)>(tripCount), std::forward<decltype(cli)>(cli));
|
|
}
|
|
|
|
void CanonicalLoopOp::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);
|
|
}
|
|
|
|
CanonicalLoopOp CanonicalLoopOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<CanonicalLoopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CanonicalLoopOp CanonicalLoopOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void CanonicalLoopOp::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&>(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);
|
|
}
|
|
|
|
CanonicalLoopOp CanonicalLoopOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<CanonicalLoopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CanonicalLoopOp CanonicalLoopOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult CanonicalLoopOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps2(*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_OpenMPOps9(*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_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CanonicalLoopOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult CanonicalLoopOp::setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
|
|
if (!dict) {
|
|
emitError() << "expected DictionaryAttr to set properties";
|
|
return ::mlir::failure();
|
|
}
|
|
// keep track of used keys in the input dictionary to be able to error out
|
|
// if there are some unknown ones.
|
|
::mlir::DenseSet<::mlir::StringAttr> usedKeys;
|
|
::mlir::MLIRContext *ctx = dict.getContext();
|
|
(void)ctx;
|
|
|
|
for (::mlir::NamedAttribute attr : dict) {
|
|
if (!usedKeys.contains(attr.getName()))
|
|
return emitError() << "unknown key '" << attr.getName() <<
|
|
"' when parsing properties dictionary";
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::CanonicalLoopOp)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::CriticalDeclareOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
CriticalDeclareOpGenericAdaptorBase::CriticalDeclareOpGenericAdaptorBase(CriticalDeclareOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::llvm::StringRef CriticalDeclareOpGenericAdaptorBase::getSymName() {
|
|
auto attr = getSymNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::mlir::IntegerAttr CriticalDeclareOpGenericAdaptorBase::getHintAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().hint);
|
|
if (!attr)
|
|
attr = ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(64), 0);
|
|
return attr;
|
|
}
|
|
|
|
uint64_t CriticalDeclareOpGenericAdaptorBase::getHint() {
|
|
auto attr = getHintAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(64), 0).getValue().getZExtValue();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
CriticalDeclareOpAdaptor::CriticalDeclareOpAdaptor(CriticalDeclareOp op) : CriticalDeclareOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult CriticalDeclareOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_hint = getProperties().hint; (void)tblgen_hint;
|
|
auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
|
|
if (!tblgen_sym_name) return emitError(loc, "'omp.critical.declare' op requires attribute 'sym_name'");
|
|
|
|
if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name))))
|
|
return emitError(loc, "'omp.critical.declare' op attribute 'sym_name' failed to satisfy constraint: string attribute");
|
|
|
|
if (tblgen_hint && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_hint))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_hint).getType().isSignlessInteger(64)))))
|
|
return emitError(loc, "'omp.critical.declare' op attribute 'hint' failed to satisfy constraint: 64-bit signless integer attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CriticalDeclareOp::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.hint;
|
|
auto attr = dict.get("hint");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `hint` 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<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `sym_name` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute CriticalDeclareOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.hint;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("hint",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
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 CriticalDeclareOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.hint.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.sym_name.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> CriticalDeclareOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "hint")
|
|
return prop.hint;
|
|
|
|
if (name == "sym_name")
|
|
return prop.sym_name;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void CriticalDeclareOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "hint") {
|
|
prop.hint = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.hint)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "sym_name") {
|
|
prop.sym_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.sym_name)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void CriticalDeclareOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.hint) attrs.append("hint", prop.hint);
|
|
|
|
if (prop.sym_name) attrs.append("sym_name", prop.sym_name);
|
|
}
|
|
|
|
::llvm::LogicalResult CriticalDeclareOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getHintAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps3(attr, "hint", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps8(attr, "sym_name", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CriticalDeclareOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.hint)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.sym_name)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CriticalDeclareOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.hint);
|
|
writer.writeAttribute(prop.sym_name);
|
|
}
|
|
|
|
::llvm::StringRef CriticalDeclareOp::getSymName() {
|
|
auto attr = getSymNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
uint64_t CriticalDeclareOp::getHint() {
|
|
auto attr = getHintAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), 0).getValue().getZExtValue();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
void CriticalDeclareOp::setSymName(::llvm::StringRef attrValue) {
|
|
getProperties().sym_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
|
|
}
|
|
|
|
void CriticalDeclareOp::setHint(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().hint;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
CriticalDeclareOp CriticalDeclareOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const CriticalDeclareOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<CriticalDeclareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CriticalDeclareOp CriticalDeclareOp::create(::mlir::ImplicitLocOpBuilder &builder, const CriticalDeclareOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void CriticalDeclareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, /*optional*/::mlir::IntegerAttr hint) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = sym_name;
|
|
if (hint) {
|
|
odsState.getOrAddProperties<Properties>().hint = hint;
|
|
}
|
|
}
|
|
|
|
CriticalDeclareOp CriticalDeclareOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::StringAttr sym_name, /*optional*/::mlir::IntegerAttr hint) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(hint)>(hint));
|
|
auto __res__ = ::llvm::dyn_cast<CriticalDeclareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CriticalDeclareOp CriticalDeclareOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::StringAttr sym_name, /*optional*/::mlir::IntegerAttr hint) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(hint)>(hint));
|
|
}
|
|
|
|
void CriticalDeclareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, /*optional*/::mlir::IntegerAttr hint) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = sym_name;
|
|
if (hint) {
|
|
odsState.getOrAddProperties<Properties>().hint = hint;
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CriticalDeclareOp CriticalDeclareOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, /*optional*/::mlir::IntegerAttr hint) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(hint)>(hint));
|
|
auto __res__ = ::llvm::dyn_cast<CriticalDeclareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CriticalDeclareOp CriticalDeclareOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, /*optional*/::mlir::IntegerAttr hint) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(hint)>(hint));
|
|
}
|
|
|
|
void CriticalDeclareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, /*optional*/uint64_t hint) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
|
|
odsState.getOrAddProperties<Properties>().hint = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), hint);
|
|
}
|
|
|
|
CriticalDeclareOp CriticalDeclareOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llvm::StringRef sym_name, /*optional*/uint64_t hint) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(hint)>(hint));
|
|
auto __res__ = ::llvm::dyn_cast<CriticalDeclareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CriticalDeclareOp CriticalDeclareOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llvm::StringRef sym_name, /*optional*/uint64_t hint) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(hint)>(hint));
|
|
}
|
|
|
|
void CriticalDeclareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, /*optional*/uint64_t hint) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
|
|
odsState.getOrAddProperties<Properties>().hint = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), hint);
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CriticalDeclareOp CriticalDeclareOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, /*optional*/uint64_t hint) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(hint)>(hint));
|
|
auto __res__ = ::llvm::dyn_cast<CriticalDeclareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CriticalDeclareOp CriticalDeclareOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, /*optional*/uint64_t hint) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(hint)>(hint));
|
|
}
|
|
|
|
void CriticalDeclareOp::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<CriticalDeclareOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
CriticalDeclareOp CriticalDeclareOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<CriticalDeclareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CriticalDeclareOp CriticalDeclareOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void CriticalDeclareOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CriticalDeclareOp CriticalDeclareOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<CriticalDeclareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CriticalDeclareOp CriticalDeclareOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult CriticalDeclareOp::verifyInvariantsImpl() {
|
|
auto tblgen_hint = getProperties().hint; (void)tblgen_hint;
|
|
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_OpenMPOps8(*this, tblgen_sym_name, "sym_name")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps3(*this, tblgen_hint, "hint")))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CriticalDeclareOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult CriticalDeclareOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::StringAttr sym_nameAttr;
|
|
::mlir::IntegerAttr hintAttr;
|
|
|
|
if (parser.parseSymbolName(sym_nameAttr))
|
|
return ::mlir::failure();
|
|
if (sym_nameAttr) result.getOrAddProperties<CriticalDeclareOp::Properties>().sym_name = sym_nameAttr;
|
|
bool hintClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("hint"))) {
|
|
|
|
if (hintClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`hint` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
hintClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseSynchronizationHint(parser, hintAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (hintAttr)
|
|
result.getOrAddProperties<CriticalDeclareOp::Properties>().hint = hintAttr;
|
|
}
|
|
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();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CriticalDeclareOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printSymbolName(getSymNameAttr().getValue());
|
|
if (false || ((getHintAttr() && getHintAttr() != ::mlir::OpBuilder((*this)->getContext()).getIntegerAttr(::mlir::OpBuilder((*this)->getContext()).getIntegerType(64), 0)))) {
|
|
_odsPrinter << ' ' << "hint";
|
|
_odsPrinter << "(";
|
|
printSynchronizationHint(_odsPrinter, *this, getHintAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("sym_name");
|
|
elidedAttrs.push_back("hint");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getHintAttr();
|
|
if(attr && (attr == odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), 0)))
|
|
elidedAttrs.push_back("hint");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::CriticalDeclareOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::CriticalDeclareOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::CriticalOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
CriticalOpGenericAdaptorBase::CriticalOpGenericAdaptorBase(CriticalOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::std::optional< ::llvm::StringRef > CriticalOpGenericAdaptorBase::getName() {
|
|
auto attr = getNameAttr();
|
|
return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
CriticalOpAdaptor::CriticalOpAdaptor(CriticalOp op) : CriticalOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult CriticalOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_name = getProperties().name; (void)tblgen_name;
|
|
|
|
if (tblgen_name && !((::llvm::isa<::mlir::FlatSymbolRefAttr>(tblgen_name))))
|
|
return emitError(loc, "'omp.critical' op attribute 'name' failed to satisfy constraint: flat symbol reference attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CriticalOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
|
|
if (!dict) {
|
|
emitError() << "expected DictionaryAttr to set properties";
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.name;
|
|
auto attr = dict.get("name");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `name` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute CriticalOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.name;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("name",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code CriticalOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.name.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> CriticalOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "name")
|
|
return prop.name;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void CriticalOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "name") {
|
|
prop.name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.name)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void CriticalOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.name) attrs.append("name", prop.name);
|
|
}
|
|
|
|
::llvm::LogicalResult CriticalOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNameAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps9(attr, "name", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CriticalOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.name)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CriticalOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.name);
|
|
}
|
|
|
|
::std::optional< ::llvm::StringRef > CriticalOp::getName() {
|
|
auto attr = getNameAttr();
|
|
return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
void CriticalOp::setName(::std::optional<::llvm::StringRef> attrValue) {
|
|
auto &odsProp = getProperties().name;
|
|
if (attrValue)
|
|
odsProp = ::mlir::SymbolRefAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void CriticalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::FlatSymbolRefAttr name) {
|
|
if (name) {
|
|
odsState.getOrAddProperties<Properties>().name = name;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
CriticalOp CriticalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::FlatSymbolRefAttr name) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(name)>(name));
|
|
auto __res__ = ::llvm::dyn_cast<CriticalOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CriticalOp CriticalOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::FlatSymbolRefAttr name) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(name)>(name));
|
|
}
|
|
|
|
void CriticalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::FlatSymbolRefAttr name) {
|
|
if (name) {
|
|
odsState.getOrAddProperties<Properties>().name = name;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CriticalOp CriticalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::FlatSymbolRefAttr name) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(name)>(name));
|
|
auto __res__ = ::llvm::dyn_cast<CriticalOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CriticalOp CriticalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::FlatSymbolRefAttr name) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(name)>(name));
|
|
}
|
|
|
|
void CriticalOp::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<CriticalOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
CriticalOp CriticalOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<CriticalOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CriticalOp CriticalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void CriticalOp::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&>(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);
|
|
}
|
|
|
|
CriticalOp CriticalOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<CriticalOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CriticalOp CriticalOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult CriticalOp::verifyInvariantsImpl() {
|
|
auto tblgen_name = getProperties().name; (void)tblgen_name;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps9(*this, tblgen_name, "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_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CriticalOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult CriticalOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::FlatSymbolRefAttr nameAttr;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
if (::mlir::succeeded(parser.parseOptionalLParen())) {
|
|
|
|
if (parser.parseCustomAttributeWithFallback(nameAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
|
|
return ::mlir::failure();
|
|
}
|
|
if (nameAttr) result.getOrAddProperties<CriticalOp::Properties>().name = nameAttr;
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
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 CriticalOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (getNameAttr()) {
|
|
_odsPrinter << "(";
|
|
_odsPrinter.printAttributeWithoutType(getNameAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getRegion());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("name");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::CriticalOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::CriticalOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::DeclareMapperInfoOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
DeclareMapperInfoOpGenericAdaptorBase::DeclareMapperInfoOpGenericAdaptorBase(DeclareMapperInfoOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> DeclareMapperInfoOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
DeclareMapperInfoOpAdaptor::DeclareMapperInfoOpAdaptor(DeclareMapperInfoOp op) : DeclareMapperInfoOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult DeclareMapperInfoOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> DeclareMapperInfoOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange DeclareMapperInfoOp::getMapVarsMutable() {
|
|
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 DeclareMapperInfoOp::getMapIteratedMutable() {
|
|
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 DeclareMapperInfoOp::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 DeclareMapperInfoOp::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 DeclareMapperInfoOp::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<mlir::Attribute> DeclareMapperInfoOp::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 DeclareMapperInfoOp::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 DeclareMapperInfoOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareMapperInfoOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareMapperInfoOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(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 DeclareMapperInfoOp::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));
|
|
;
|
|
}
|
|
}
|
|
|
|
DeclareMapperInfoOp DeclareMapperInfoOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const DeclareMapperInfoOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareMapperInfoOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareMapperInfoOp DeclareMapperInfoOp::create(::mlir::ImplicitLocOpBuilder &builder, const DeclareMapperInfoOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void DeclareMapperInfoOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated) {
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
}
|
|
|
|
DeclareMapperInfoOp DeclareMapperInfoOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareMapperInfoOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareMapperInfoOp DeclareMapperInfoOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated));
|
|
}
|
|
|
|
void DeclareMapperInfoOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated) {
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DeclareMapperInfoOp DeclareMapperInfoOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareMapperInfoOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareMapperInfoOp DeclareMapperInfoOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated));
|
|
}
|
|
|
|
void DeclareMapperInfoOp::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<DeclareMapperInfoOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
DeclareMapperInfoOp DeclareMapperInfoOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareMapperInfoOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareMapperInfoOp DeclareMapperInfoOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void DeclareMapperInfoOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DeclareMapperInfoOp DeclareMapperInfoOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareMapperInfoOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareMapperInfoOp DeclareMapperInfoOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareMapperInfoOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps11(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareMapperInfoOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult DeclareMapperInfoOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> map_varsOperands;
|
|
::llvm::SMLoc map_varsOperandsLoc;
|
|
(void)map_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> map_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> map_iteratedOperands;
|
|
::llvm::SMLoc map_iteratedOperandsLoc;
|
|
(void)map_iteratedOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> map_iteratedTypes;
|
|
bool map_entriesClause = false;
|
|
bool map_iteratedClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("map_entries"))) {
|
|
|
|
if (map_entriesClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`map_entries` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
map_entriesClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
map_varsOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(map_varsOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(map_varsTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("map_iterated"))) {
|
|
|
|
if (map_iteratedClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`map_iterated` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
map_iteratedClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
map_iteratedOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(map_iteratedOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(map_iteratedTypes))
|
|
return ::mlir::failure();
|
|
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<int32_t>({static_cast<int32_t>(map_varsOperands.size()), static_cast<int32_t>(map_iteratedOperands.size())}), result.getOrAddProperties<DeclareMapperInfoOp::Properties>().operandSegmentSizes.begin());
|
|
if (parser.resolveOperands(map_varsOperands, map_varsTypes, map_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(map_iteratedOperands, map_iteratedTypes, map_iteratedOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void DeclareMapperInfoOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getMapVars().size()) {
|
|
_odsPrinter << ' ' << "map_entries";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getMapVars();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getMapVars().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getMapIterated().size()) {
|
|
_odsPrinter << ' ' << "map_iterated";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getMapIterated();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getMapIterated().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::DeclareMapperInfoOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::DeclareMapperInfoOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::DeclareMapperOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
DeclareMapperOpGenericAdaptorBase::DeclareMapperOpGenericAdaptorBase(DeclareMapperOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::llvm::StringRef DeclareMapperOpGenericAdaptorBase::getSymName() {
|
|
auto attr = getSymNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::mlir::Type DeclareMapperOpGenericAdaptorBase::getType() {
|
|
auto attr = getTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
DeclareMapperOpAdaptor::DeclareMapperOpAdaptor(DeclareMapperOp op) : DeclareMapperOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult DeclareMapperOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
|
|
if (!tblgen_sym_name) return emitError(loc, "'omp.declare_mapper' op requires attribute 'sym_name'");
|
|
auto tblgen_type = getProperties().type; (void)tblgen_type;
|
|
if (!tblgen_type) return emitError(loc, "'omp.declare_mapper' op requires attribute 'type'");
|
|
|
|
if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name))))
|
|
return emitError(loc, "'omp.declare_mapper' 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, "'omp.declare_mapper' op attribute 'type' failed to satisfy constraint: any type attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareMapperOp::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<std::remove_reference_t<decltype(propStorage)>>(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<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute DeclareMapperOp::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 DeclareMapperOp::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<mlir::Attribute> DeclareMapperOp::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 DeclareMapperOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "sym_name") {
|
|
prop.sym_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.sym_name)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "type") {
|
|
prop.type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.type)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void DeclareMapperOp::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 DeclareMapperOp::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_OpenMPOps8(attr, "sym_name", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(attr, "type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareMapperOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (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 DeclareMapperOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.sym_name);
|
|
writer.writeAttribute(prop.type);
|
|
}
|
|
|
|
::llvm::StringRef DeclareMapperOp::getSymName() {
|
|
auto attr = getSymNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::mlir::Type DeclareMapperOp::getType() {
|
|
auto attr = getTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
void DeclareMapperOp::setSymName(::llvm::StringRef attrValue) {
|
|
getProperties().sym_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
|
|
}
|
|
|
|
void DeclareMapperOp::setType(::mlir::Type attrValue) {
|
|
getProperties().type = ::mlir::TypeAttr::get(attrValue);
|
|
}
|
|
|
|
void DeclareMapperOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = sym_name;
|
|
odsState.getOrAddProperties<Properties>().type = type;
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
DeclareMapperOp DeclareMapperOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareMapperOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareMapperOp DeclareMapperOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type));
|
|
}
|
|
|
|
void DeclareMapperOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = sym_name;
|
|
odsState.getOrAddProperties<Properties>().type = type;
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DeclareMapperOp DeclareMapperOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareMapperOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareMapperOp DeclareMapperOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type));
|
|
}
|
|
|
|
void DeclareMapperOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, ::mlir::Type type) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
|
|
odsState.getOrAddProperties<Properties>().type = ::mlir::TypeAttr::get(type);
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
DeclareMapperOp DeclareMapperOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llvm::StringRef sym_name, ::mlir::Type type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareMapperOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareMapperOp DeclareMapperOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llvm::StringRef sym_name, ::mlir::Type type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type));
|
|
}
|
|
|
|
void DeclareMapperOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
|
|
odsState.getOrAddProperties<Properties>().type = ::mlir::TypeAttr::get(type);
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DeclareMapperOp DeclareMapperOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareMapperOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareMapperOp DeclareMapperOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type));
|
|
}
|
|
|
|
void DeclareMapperOp::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<DeclareMapperOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
DeclareMapperOp DeclareMapperOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareMapperOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareMapperOp DeclareMapperOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void DeclareMapperOp::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&>(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);
|
|
}
|
|
|
|
DeclareMapperOp DeclareMapperOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareMapperOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareMapperOp DeclareMapperOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareMapperOp::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_OpenMPOps8(*this, tblgen_sym_name, "sym_name")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(*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_OpenMPOps2(*this, region, "body", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareMapperOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult DeclareMapperOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::StringAttr sym_nameAttr;
|
|
::mlir::TypeAttr typeAttr;
|
|
std::unique_ptr<::mlir::Region> bodyRegion = std::make_unique<::mlir::Region>();
|
|
|
|
if (parser.parseSymbolName(sym_nameAttr))
|
|
return ::mlir::failure();
|
|
if (sym_nameAttr) result.getOrAddProperties<DeclareMapperOp::Properties>().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<DeclareMapperOp::Properties>().type = typeAttr;
|
|
|
|
if (parser.parseRegion(*bodyRegion))
|
|
return ::mlir::failure();
|
|
|
|
if (bodyRegion->empty()) bodyRegion->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(bodyRegion));
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void DeclareMapperOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printSymbolName(getSymNameAttr().getValue());
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printAttributeWithoutType(getTypeAttr());
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getBody());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("sym_name");
|
|
elidedAttrs.push_back("type");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::DeclareMapperOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::DeclareMapperOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::DeclareReductionOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
DeclareReductionOpGenericAdaptorBase::DeclareReductionOpGenericAdaptorBase(DeclareReductionOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::llvm::StringRef DeclareReductionOpGenericAdaptorBase::getSymName() {
|
|
auto attr = getSymNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::mlir::Type DeclareReductionOpGenericAdaptorBase::getType() {
|
|
auto attr = getTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::std::optional<::mlir::Type> DeclareReductionOpGenericAdaptorBase::getByrefElementType() {
|
|
auto attr = getByrefElementTypeAttr();
|
|
return attr ? ::std::optional<::mlir::Type>(::llvm::cast<::mlir::Type>(attr.getValue())) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
DeclareReductionOpAdaptor::DeclareReductionOpAdaptor(DeclareReductionOp op) : DeclareReductionOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult DeclareReductionOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_byref_element_type = getProperties().byref_element_type; (void)tblgen_byref_element_type;
|
|
auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
|
|
if (!tblgen_sym_name) return emitError(loc, "'omp.declare_reduction' op requires attribute 'sym_name'");
|
|
auto tblgen_type = getProperties().type; (void)tblgen_type;
|
|
if (!tblgen_type) return emitError(loc, "'omp.declare_reduction' op requires attribute 'type'");
|
|
|
|
if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name))))
|
|
return emitError(loc, "'omp.declare_reduction' 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, "'omp.declare_reduction' op attribute 'type' failed to satisfy constraint: any type attribute");
|
|
|
|
if (tblgen_byref_element_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_byref_element_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_byref_element_type).getValue()))) && ((true))))
|
|
return emitError(loc, "'omp.declare_reduction' op attribute 'byref_element_type' failed to satisfy constraint: any type attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareReductionOp::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.byref_element_type;
|
|
auto attr = dict.get("byref_element_type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `byref_element_type` 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<std::remove_reference_t<decltype(propStorage)>>(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<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute DeclareReductionOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.byref_element_type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("byref_element_type",
|
|
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 DeclareReductionOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.byref_element_type.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.sym_name.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.type.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> DeclareReductionOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "byref_element_type")
|
|
return prop.byref_element_type;
|
|
|
|
if (name == "sym_name")
|
|
return prop.sym_name;
|
|
|
|
if (name == "type")
|
|
return prop.type;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void DeclareReductionOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "byref_element_type") {
|
|
prop.byref_element_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.byref_element_type)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "sym_name") {
|
|
prop.sym_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.sym_name)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "type") {
|
|
prop.type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.type)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void DeclareReductionOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.byref_element_type) attrs.append("byref_element_type", prop.byref_element_type);
|
|
|
|
if (prop.sym_name) attrs.append("sym_name", prop.sym_name);
|
|
|
|
if (prop.type) attrs.append("type", prop.type);
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareReductionOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getByrefElementTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(attr, "byref_element_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps8(attr, "sym_name", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(attr, "type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareReductionOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.byref_element_type)))
|
|
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 DeclareReductionOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.byref_element_type);
|
|
writer.writeAttribute(prop.sym_name);
|
|
writer.writeAttribute(prop.type);
|
|
}
|
|
|
|
::llvm::StringRef DeclareReductionOp::getSymName() {
|
|
auto attr = getSymNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::mlir::Type DeclareReductionOp::getType() {
|
|
auto attr = getTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::std::optional<::mlir::Type> DeclareReductionOp::getByrefElementType() {
|
|
auto attr = getByrefElementTypeAttr();
|
|
return attr ? ::std::optional<::mlir::Type>(::llvm::cast<::mlir::Type>(attr.getValue())) : (::std::nullopt);
|
|
}
|
|
|
|
void DeclareReductionOp::setSymName(::llvm::StringRef attrValue) {
|
|
getProperties().sym_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
|
|
}
|
|
|
|
void DeclareReductionOp::setType(::mlir::Type attrValue) {
|
|
getProperties().type = ::mlir::TypeAttr::get(attrValue);
|
|
}
|
|
|
|
void DeclareReductionOp::setByrefElementType(::std::optional<::mlir::Type> attrValue) {
|
|
auto &odsProp = getProperties().byref_element_type;
|
|
if (attrValue)
|
|
odsProp = ::mlir::TypeAttr::get(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void DeclareReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, /*optional*/::mlir::TypeAttr byref_element_type) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = sym_name;
|
|
odsState.getOrAddProperties<Properties>().type = type;
|
|
if (byref_element_type) {
|
|
odsState.getOrAddProperties<Properties>().byref_element_type = byref_element_type;
|
|
}
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
DeclareReductionOp DeclareReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, /*optional*/::mlir::TypeAttr byref_element_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type), std::forward<decltype(byref_element_type)>(byref_element_type));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareReductionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareReductionOp DeclareReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, /*optional*/::mlir::TypeAttr byref_element_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type), std::forward<decltype(byref_element_type)>(byref_element_type));
|
|
}
|
|
|
|
void DeclareReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, /*optional*/::mlir::TypeAttr byref_element_type) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = sym_name;
|
|
odsState.getOrAddProperties<Properties>().type = type;
|
|
if (byref_element_type) {
|
|
odsState.getOrAddProperties<Properties>().byref_element_type = byref_element_type;
|
|
}
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DeclareReductionOp DeclareReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, /*optional*/::mlir::TypeAttr byref_element_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type), std::forward<decltype(byref_element_type)>(byref_element_type));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareReductionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareReductionOp DeclareReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, /*optional*/::mlir::TypeAttr byref_element_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type), std::forward<decltype(byref_element_type)>(byref_element_type));
|
|
}
|
|
|
|
void DeclareReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, ::mlir::Type type, /*optional*/::mlir::TypeAttr byref_element_type) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
|
|
odsState.getOrAddProperties<Properties>().type = ::mlir::TypeAttr::get(type);
|
|
if (byref_element_type) {
|
|
odsState.getOrAddProperties<Properties>().byref_element_type = byref_element_type;
|
|
}
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
DeclareReductionOp DeclareReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llvm::StringRef sym_name, ::mlir::Type type, /*optional*/::mlir::TypeAttr byref_element_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type), std::forward<decltype(byref_element_type)>(byref_element_type));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareReductionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareReductionOp DeclareReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llvm::StringRef sym_name, ::mlir::Type type, /*optional*/::mlir::TypeAttr byref_element_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type), std::forward<decltype(byref_element_type)>(byref_element_type));
|
|
}
|
|
|
|
void DeclareReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type, /*optional*/::mlir::TypeAttr byref_element_type) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
|
|
odsState.getOrAddProperties<Properties>().type = ::mlir::TypeAttr::get(type);
|
|
if (byref_element_type) {
|
|
odsState.getOrAddProperties<Properties>().byref_element_type = byref_element_type;
|
|
}
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DeclareReductionOp DeclareReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type, /*optional*/::mlir::TypeAttr byref_element_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type), std::forward<decltype(byref_element_type)>(byref_element_type));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareReductionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareReductionOp DeclareReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type, /*optional*/::mlir::TypeAttr byref_element_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type), std::forward<decltype(byref_element_type)>(byref_element_type));
|
|
}
|
|
|
|
void DeclareReductionOp::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 != 6; ++i)
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<DeclareReductionOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
DeclareReductionOp DeclareReductionOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareReductionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareReductionOp DeclareReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void DeclareReductionOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
for (unsigned i = 0; i != 6; ++i)
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DeclareReductionOp DeclareReductionOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareReductionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareReductionOp DeclareReductionOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareReductionOp::verifyInvariantsImpl() {
|
|
auto tblgen_byref_element_type = getProperties().byref_element_type; (void)tblgen_byref_element_type;
|
|
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_OpenMPOps8(*this, tblgen_sym_name, "sym_name")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(*this, tblgen_type, "type")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(*this, tblgen_byref_element_type, "byref_element_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_OpenMPOps3(*this, region, "allocRegion", index++)))
|
|
return ::mlir::failure();
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps2(*this, region, "initializerRegion", index++)))
|
|
return ::mlir::failure();
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(2)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps2(*this, region, "reductionRegion", index++)))
|
|
return ::mlir::failure();
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(3)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps2(*this, region, "atomicReductionRegion", index++)))
|
|
return ::mlir::failure();
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(4)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps2(*this, region, "cleanupRegion", index++)))
|
|
return ::mlir::failure();
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(5)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps3(*this, region, "dataPtrPtrRegion", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareReductionOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult DeclareReductionOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::StringAttr sym_nameAttr;
|
|
::mlir::TypeAttr typeAttr;
|
|
std::unique_ptr<::mlir::Region> allocRegionRegion = std::make_unique<::mlir::Region>();
|
|
std::unique_ptr<::mlir::Region> initializerRegionRegion = std::make_unique<::mlir::Region>();
|
|
std::unique_ptr<::mlir::Region> reductionRegionRegion = std::make_unique<::mlir::Region>();
|
|
std::unique_ptr<::mlir::Region> atomicReductionRegionRegion = std::make_unique<::mlir::Region>();
|
|
std::unique_ptr<::mlir::Region> cleanupRegionRegion = std::make_unique<::mlir::Region>();
|
|
std::unique_ptr<::mlir::Region> dataPtrPtrRegionRegion = std::make_unique<::mlir::Region>();
|
|
|
|
if (parser.parseSymbolName(sym_nameAttr))
|
|
return ::mlir::failure();
|
|
if (sym_nameAttr) result.getOrAddProperties<DeclareReductionOp::Properties>().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<DeclareReductionOp::Properties>().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 (::mlir::succeeded(parser.parseOptionalKeyword("alloc"))) {
|
|
|
|
if (parser.parseRegion(*allocRegionRegion))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.parseKeyword("init"))
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseRegion(*initializerRegionRegion))
|
|
return ::mlir::failure();
|
|
if (parser.parseKeyword("combiner"))
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseRegion(*reductionRegionRegion))
|
|
return ::mlir::failure();
|
|
if (::mlir::succeeded(parser.parseOptionalKeyword("atomic"))) {
|
|
|
|
if (parser.parseRegion(*atomicReductionRegionRegion))
|
|
return ::mlir::failure();
|
|
}
|
|
if (::mlir::succeeded(parser.parseOptionalKeyword("cleanup"))) {
|
|
|
|
if (parser.parseRegion(*cleanupRegionRegion))
|
|
return ::mlir::failure();
|
|
}
|
|
if (::mlir::succeeded(parser.parseOptionalKeyword("data_ptr_ptr"))) {
|
|
|
|
if (parser.parseRegion(*dataPtrPtrRegionRegion))
|
|
return ::mlir::failure();
|
|
}
|
|
result.addRegion(std::move(allocRegionRegion));
|
|
result.addRegion(std::move(initializerRegionRegion));
|
|
result.addRegion(std::move(reductionRegionRegion));
|
|
result.addRegion(std::move(atomicReductionRegionRegion));
|
|
result.addRegion(std::move(cleanupRegionRegion));
|
|
result.addRegion(std::move(dataPtrPtrRegionRegion));
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void DeclareReductionOp::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);
|
|
if (!getAllocRegion().empty()) {
|
|
_odsPrinter << ' ' << "alloc";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getAllocRegion());
|
|
}
|
|
_odsPrinter << ' ' << "init";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getInitializerRegion());
|
|
_odsPrinter << ' ' << "combiner";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getReductionRegion());
|
|
if (!getAtomicReductionRegion().empty()) {
|
|
_odsPrinter << ' ' << "atomic";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getAtomicReductionRegion());
|
|
}
|
|
if (!getCleanupRegion().empty()) {
|
|
_odsPrinter << ' ' << "cleanup";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getCleanupRegion());
|
|
}
|
|
if (!getDataPtrPtrRegion().empty()) {
|
|
_odsPrinter << ' ' << "data_ptr_ptr";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getDataPtrPtrRegion());
|
|
}
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::DeclareReductionOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::DeclareReductionOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::DeclareSimdOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
DeclareSimdOpGenericAdaptorBase::DeclareSimdOpGenericAdaptorBase(DeclareSimdOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> DeclareSimdOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > DeclareSimdOpGenericAdaptorBase::getAlignments() {
|
|
auto attr = getAlignmentsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr DeclareSimdOpGenericAdaptorBase::getInbranchAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().inbranch);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool DeclareSimdOpGenericAdaptorBase::getInbranch() {
|
|
auto attr = getInbranchAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > DeclareSimdOpGenericAdaptorBase::getLinearVarTypes() {
|
|
auto attr = getLinearVarTypesAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > DeclareSimdOpGenericAdaptorBase::getLinearModifiers() {
|
|
auto attr = getLinearModifiersAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr DeclareSimdOpGenericAdaptorBase::getNotinbranchAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().notinbranch);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool DeclareSimdOpGenericAdaptorBase::getNotinbranch() {
|
|
auto attr = getNotinbranchAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<uint64_t> DeclareSimdOpGenericAdaptorBase::getSimdlen() {
|
|
auto attr = getSimdlenAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
DeclareSimdOpAdaptor::DeclareSimdOpAdaptor(DeclareSimdOp op) : DeclareSimdOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult DeclareSimdOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_alignments = getProperties().alignments; (void)tblgen_alignments;
|
|
auto tblgen_inbranch = getProperties().inbranch; (void)tblgen_inbranch;
|
|
auto tblgen_linear_modifiers = getProperties().linear_modifiers; (void)tblgen_linear_modifiers;
|
|
auto tblgen_linear_var_types = getProperties().linear_var_types; (void)tblgen_linear_var_types;
|
|
auto tblgen_notinbranch = getProperties().notinbranch; (void)tblgen_notinbranch;
|
|
auto tblgen_simdlen = getProperties().simdlen; (void)tblgen_simdlen;
|
|
|
|
if (tblgen_alignments && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_alignments))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_alignments), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); }))))
|
|
return emitError(loc, "'omp.declare_simd' op attribute 'alignments' failed to satisfy constraint: 64-bit integer array attribute");
|
|
|
|
if (tblgen_inbranch && !((::llvm::isa<::mlir::UnitAttr>(tblgen_inbranch))))
|
|
return emitError(loc, "'omp.declare_simd' op attribute 'inbranch' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_linear_var_types && !((::llvm::isa<::mlir::ArrayAttr>(tblgen_linear_var_types))))
|
|
return emitError(loc, "'omp.declare_simd' op attribute 'linear_var_types' failed to satisfy constraint: array attribute");
|
|
|
|
if (tblgen_linear_modifiers && !((::llvm::isa<::mlir::ArrayAttr>(tblgen_linear_modifiers))))
|
|
return emitError(loc, "'omp.declare_simd' op attribute 'linear_modifiers' failed to satisfy constraint: array attribute");
|
|
|
|
if (tblgen_notinbranch && !((::llvm::isa<::mlir::UnitAttr>(tblgen_notinbranch))))
|
|
return emitError(loc, "'omp.declare_simd' op attribute 'notinbranch' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_simdlen && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_simdlen))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_simdlen).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_simdlen).getValue().isStrictlyPositive()))))
|
|
return emitError(loc, "'omp.declare_simd' op attribute 'simdlen' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> DeclareSimdOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange DeclareSimdOp::getAlignedVarsMutable() {
|
|
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 DeclareSimdOp::getLinearVarsMutable() {
|
|
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 DeclareSimdOp::getLinearStepVarsMutable() {
|
|
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 DeclareSimdOp::getUniformVarsMutable() {
|
|
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 DeclareSimdOp::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.alignments;
|
|
auto attr = dict.get("alignments");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `alignments` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.inbranch;
|
|
auto attr = dict.get("inbranch");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `inbranch` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.linear_modifiers;
|
|
auto attr = dict.get("linear_modifiers");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `linear_modifiers` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.linear_var_types;
|
|
auto attr = dict.get("linear_var_types");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `linear_var_types` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.notinbranch;
|
|
auto attr = dict.get("notinbranch");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `notinbranch` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.simdlen;
|
|
auto attr = dict.get("simdlen");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `simdlen` 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 DeclareSimdOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.alignments;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("alignments",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.inbranch;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("inbranch",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.linear_modifiers;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("linear_modifiers",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.linear_var_types;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("linear_var_types",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.notinbranch;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("notinbranch",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.simdlen;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("simdlen",
|
|
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 DeclareSimdOp::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.alignments.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.inbranch.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.linear_modifiers.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.linear_var_types.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.notinbranch.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.simdlen.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> DeclareSimdOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "alignments")
|
|
return prop.alignments;
|
|
|
|
if (name == "inbranch")
|
|
return prop.inbranch;
|
|
|
|
if (name == "linear_modifiers")
|
|
return prop.linear_modifiers;
|
|
|
|
if (name == "linear_var_types")
|
|
return prop.linear_var_types;
|
|
|
|
if (name == "notinbranch")
|
|
return prop.notinbranch;
|
|
|
|
if (name == "simdlen")
|
|
return prop.simdlen;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void DeclareSimdOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "alignments") {
|
|
prop.alignments = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.alignments)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "inbranch") {
|
|
prop.inbranch = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.inbranch)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "linear_modifiers") {
|
|
prop.linear_modifiers = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.linear_modifiers)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "linear_var_types") {
|
|
prop.linear_var_types = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.linear_var_types)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "notinbranch") {
|
|
prop.notinbranch = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.notinbranch)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "simdlen") {
|
|
prop.simdlen = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.simdlen)>>(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 DeclareSimdOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.alignments) attrs.append("alignments", prop.alignments);
|
|
|
|
if (prop.inbranch) attrs.append("inbranch", prop.inbranch);
|
|
|
|
if (prop.linear_modifiers) attrs.append("linear_modifiers", prop.linear_modifiers);
|
|
|
|
if (prop.linear_var_types) attrs.append("linear_var_types", prop.linear_var_types);
|
|
|
|
if (prop.notinbranch) attrs.append("notinbranch", prop.notinbranch);
|
|
|
|
if (prop.simdlen) attrs.append("simdlen", prop.simdlen);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareSimdOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAlignmentsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps10(attr, "alignments", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getInbranchAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "inbranch", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getLinearModifiersAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps11(attr, "linear_modifiers", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getLinearVarTypesAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps11(attr, "linear_var_types", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNotinbranchAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "notinbranch", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getSimdlenAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps2(attr, "simdlen", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareSimdOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.alignments)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.inbranch)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.linear_modifiers)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.linear_var_types)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.notinbranch)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.simdlen)))
|
|
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 DeclareSimdOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.alignments);
|
|
|
|
writer.writeOptionalAttribute(prop.inbranch);
|
|
|
|
writer.writeOptionalAttribute(prop.linear_modifiers);
|
|
|
|
writer.writeOptionalAttribute(prop.linear_var_types);
|
|
|
|
writer.writeOptionalAttribute(prop.notinbranch);
|
|
|
|
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
|
|
}
|
|
|
|
writer.writeOptionalAttribute(prop.simdlen);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > DeclareSimdOp::getAlignments() {
|
|
auto attr = getAlignmentsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool DeclareSimdOp::getInbranch() {
|
|
auto attr = getInbranchAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > DeclareSimdOp::getLinearVarTypes() {
|
|
auto attr = getLinearVarTypesAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > DeclareSimdOp::getLinearModifiers() {
|
|
auto attr = getLinearModifiersAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool DeclareSimdOp::getNotinbranch() {
|
|
auto attr = getNotinbranchAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<uint64_t> DeclareSimdOp::getSimdlen() {
|
|
auto attr = getSimdlenAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
void DeclareSimdOp::setInbranch(bool attrValue) {
|
|
auto &odsProp = getProperties().inbranch;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void DeclareSimdOp::setNotinbranch(bool attrValue) {
|
|
auto &odsProp = getProperties().notinbranch;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void DeclareSimdOp::setSimdlen(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().simdlen;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
DeclareSimdOp DeclareSimdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const DeclareSimdOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareSimdOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareSimdOp DeclareSimdOp::create(::mlir::ImplicitLocOpBuilder &builder, const DeclareSimdOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void DeclareSimdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::UnitAttr inbranch, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/::mlir::UnitAttr notinbranch, /*optional*/::mlir::IntegerAttr simdlen, ::mlir::ValueRange uniform_vars) {
|
|
odsState.addOperands(aligned_vars);
|
|
odsState.addOperands(linear_vars);
|
|
odsState.addOperands(linear_step_vars);
|
|
odsState.addOperands(uniform_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(aligned_vars.size()), static_cast<int32_t>(linear_vars.size()), static_cast<int32_t>(linear_step_vars.size()), static_cast<int32_t>(uniform_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (alignments) {
|
|
odsState.getOrAddProperties<Properties>().alignments = alignments;
|
|
}
|
|
if (inbranch) {
|
|
odsState.getOrAddProperties<Properties>().inbranch = inbranch;
|
|
}
|
|
if (linear_var_types) {
|
|
odsState.getOrAddProperties<Properties>().linear_var_types = linear_var_types;
|
|
}
|
|
if (linear_modifiers) {
|
|
odsState.getOrAddProperties<Properties>().linear_modifiers = linear_modifiers;
|
|
}
|
|
if (notinbranch) {
|
|
odsState.getOrAddProperties<Properties>().notinbranch = notinbranch;
|
|
}
|
|
if (simdlen) {
|
|
odsState.getOrAddProperties<Properties>().simdlen = simdlen;
|
|
}
|
|
}
|
|
|
|
DeclareSimdOp DeclareSimdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::UnitAttr inbranch, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/::mlir::UnitAttr notinbranch, /*optional*/::mlir::IntegerAttr simdlen, ::mlir::ValueRange uniform_vars) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(aligned_vars)>(aligned_vars), std::forward<decltype(alignments)>(alignments), std::forward<decltype(inbranch)>(inbranch), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(notinbranch)>(notinbranch), std::forward<decltype(simdlen)>(simdlen), std::forward<decltype(uniform_vars)>(uniform_vars));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareSimdOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareSimdOp DeclareSimdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::UnitAttr inbranch, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/::mlir::UnitAttr notinbranch, /*optional*/::mlir::IntegerAttr simdlen, ::mlir::ValueRange uniform_vars) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(aligned_vars)>(aligned_vars), std::forward<decltype(alignments)>(alignments), std::forward<decltype(inbranch)>(inbranch), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(notinbranch)>(notinbranch), std::forward<decltype(simdlen)>(simdlen), std::forward<decltype(uniform_vars)>(uniform_vars));
|
|
}
|
|
|
|
void DeclareSimdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::UnitAttr inbranch, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/::mlir::UnitAttr notinbranch, /*optional*/::mlir::IntegerAttr simdlen, ::mlir::ValueRange uniform_vars) {
|
|
odsState.addOperands(aligned_vars);
|
|
odsState.addOperands(linear_vars);
|
|
odsState.addOperands(linear_step_vars);
|
|
odsState.addOperands(uniform_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(aligned_vars.size()), static_cast<int32_t>(linear_vars.size()), static_cast<int32_t>(linear_step_vars.size()), static_cast<int32_t>(uniform_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (alignments) {
|
|
odsState.getOrAddProperties<Properties>().alignments = alignments;
|
|
}
|
|
if (inbranch) {
|
|
odsState.getOrAddProperties<Properties>().inbranch = inbranch;
|
|
}
|
|
if (linear_var_types) {
|
|
odsState.getOrAddProperties<Properties>().linear_var_types = linear_var_types;
|
|
}
|
|
if (linear_modifiers) {
|
|
odsState.getOrAddProperties<Properties>().linear_modifiers = linear_modifiers;
|
|
}
|
|
if (notinbranch) {
|
|
odsState.getOrAddProperties<Properties>().notinbranch = notinbranch;
|
|
}
|
|
if (simdlen) {
|
|
odsState.getOrAddProperties<Properties>().simdlen = simdlen;
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DeclareSimdOp DeclareSimdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::UnitAttr inbranch, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/::mlir::UnitAttr notinbranch, /*optional*/::mlir::IntegerAttr simdlen, ::mlir::ValueRange uniform_vars) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(aligned_vars)>(aligned_vars), std::forward<decltype(alignments)>(alignments), std::forward<decltype(inbranch)>(inbranch), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(notinbranch)>(notinbranch), std::forward<decltype(simdlen)>(simdlen), std::forward<decltype(uniform_vars)>(uniform_vars));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareSimdOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareSimdOp DeclareSimdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::UnitAttr inbranch, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/::mlir::UnitAttr notinbranch, /*optional*/::mlir::IntegerAttr simdlen, ::mlir::ValueRange uniform_vars) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(aligned_vars)>(aligned_vars), std::forward<decltype(alignments)>(alignments), std::forward<decltype(inbranch)>(inbranch), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(notinbranch)>(notinbranch), std::forward<decltype(simdlen)>(simdlen), std::forward<decltype(uniform_vars)>(uniform_vars));
|
|
}
|
|
|
|
void DeclareSimdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/bool inbranch, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/bool notinbranch, /*optional*/::mlir::IntegerAttr simdlen, ::mlir::ValueRange uniform_vars) {
|
|
odsState.addOperands(aligned_vars);
|
|
odsState.addOperands(linear_vars);
|
|
odsState.addOperands(linear_step_vars);
|
|
odsState.addOperands(uniform_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(aligned_vars.size()), static_cast<int32_t>(linear_vars.size()), static_cast<int32_t>(linear_step_vars.size()), static_cast<int32_t>(uniform_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (alignments) {
|
|
odsState.getOrAddProperties<Properties>().alignments = alignments;
|
|
}
|
|
if (inbranch) {
|
|
odsState.getOrAddProperties<Properties>().inbranch = ((inbranch) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (linear_var_types) {
|
|
odsState.getOrAddProperties<Properties>().linear_var_types = linear_var_types;
|
|
}
|
|
if (linear_modifiers) {
|
|
odsState.getOrAddProperties<Properties>().linear_modifiers = linear_modifiers;
|
|
}
|
|
if (notinbranch) {
|
|
odsState.getOrAddProperties<Properties>().notinbranch = ((notinbranch) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (simdlen) {
|
|
odsState.getOrAddProperties<Properties>().simdlen = simdlen;
|
|
}
|
|
}
|
|
|
|
DeclareSimdOp DeclareSimdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/bool inbranch, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/bool notinbranch, /*optional*/::mlir::IntegerAttr simdlen, ::mlir::ValueRange uniform_vars) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(aligned_vars)>(aligned_vars), std::forward<decltype(alignments)>(alignments), std::forward<decltype(inbranch)>(inbranch), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(notinbranch)>(notinbranch), std::forward<decltype(simdlen)>(simdlen), std::forward<decltype(uniform_vars)>(uniform_vars));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareSimdOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareSimdOp DeclareSimdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/bool inbranch, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/bool notinbranch, /*optional*/::mlir::IntegerAttr simdlen, ::mlir::ValueRange uniform_vars) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(aligned_vars)>(aligned_vars), std::forward<decltype(alignments)>(alignments), std::forward<decltype(inbranch)>(inbranch), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(notinbranch)>(notinbranch), std::forward<decltype(simdlen)>(simdlen), std::forward<decltype(uniform_vars)>(uniform_vars));
|
|
}
|
|
|
|
void DeclareSimdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/bool inbranch, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/bool notinbranch, /*optional*/::mlir::IntegerAttr simdlen, ::mlir::ValueRange uniform_vars) {
|
|
odsState.addOperands(aligned_vars);
|
|
odsState.addOperands(linear_vars);
|
|
odsState.addOperands(linear_step_vars);
|
|
odsState.addOperands(uniform_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(aligned_vars.size()), static_cast<int32_t>(linear_vars.size()), static_cast<int32_t>(linear_step_vars.size()), static_cast<int32_t>(uniform_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (alignments) {
|
|
odsState.getOrAddProperties<Properties>().alignments = alignments;
|
|
}
|
|
if (inbranch) {
|
|
odsState.getOrAddProperties<Properties>().inbranch = ((inbranch) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (linear_var_types) {
|
|
odsState.getOrAddProperties<Properties>().linear_var_types = linear_var_types;
|
|
}
|
|
if (linear_modifiers) {
|
|
odsState.getOrAddProperties<Properties>().linear_modifiers = linear_modifiers;
|
|
}
|
|
if (notinbranch) {
|
|
odsState.getOrAddProperties<Properties>().notinbranch = ((notinbranch) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (simdlen) {
|
|
odsState.getOrAddProperties<Properties>().simdlen = simdlen;
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DeclareSimdOp DeclareSimdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/bool inbranch, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/bool notinbranch, /*optional*/::mlir::IntegerAttr simdlen, ::mlir::ValueRange uniform_vars) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(aligned_vars)>(aligned_vars), std::forward<decltype(alignments)>(alignments), std::forward<decltype(inbranch)>(inbranch), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(notinbranch)>(notinbranch), std::forward<decltype(simdlen)>(simdlen), std::forward<decltype(uniform_vars)>(uniform_vars));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareSimdOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareSimdOp DeclareSimdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/bool inbranch, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/bool notinbranch, /*optional*/::mlir::IntegerAttr simdlen, ::mlir::ValueRange uniform_vars) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(aligned_vars)>(aligned_vars), std::forward<decltype(alignments)>(alignments), std::forward<decltype(inbranch)>(inbranch), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(notinbranch)>(notinbranch), std::forward<decltype(simdlen)>(simdlen), std::forward<decltype(uniform_vars)>(uniform_vars));
|
|
}
|
|
|
|
void DeclareSimdOp::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<DeclareSimdOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
DeclareSimdOp DeclareSimdOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareSimdOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareSimdOp DeclareSimdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void DeclareSimdOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DeclareSimdOp DeclareSimdOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<DeclareSimdOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DeclareSimdOp DeclareSimdOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareSimdOp::verifyInvariantsImpl() {
|
|
auto tblgen_alignments = getProperties().alignments; (void)tblgen_alignments;
|
|
auto tblgen_inbranch = getProperties().inbranch; (void)tblgen_inbranch;
|
|
auto tblgen_linear_modifiers = getProperties().linear_modifiers; (void)tblgen_linear_modifiers;
|
|
auto tblgen_linear_var_types = getProperties().linear_var_types; (void)tblgen_linear_var_types;
|
|
auto tblgen_notinbranch = getProperties().notinbranch; (void)tblgen_notinbranch;
|
|
auto tblgen_simdlen = getProperties().simdlen; (void)tblgen_simdlen;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps10(*this, tblgen_alignments, "alignments")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_inbranch, "inbranch")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps11(*this, tblgen_linear_var_types, "linear_var_types")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps11(*this, tblgen_linear_modifiers, "linear_modifiers")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_notinbranch, "notinbranch")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps2(*this, tblgen_simdlen, "simdlen")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps12(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DeclareSimdOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult DeclareSimdOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> aligned_varsOperands;
|
|
::llvm::SMLoc aligned_varsOperandsLoc;
|
|
(void)aligned_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> aligned_varsTypes;
|
|
::mlir::ArrayAttr alignmentsAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> linear_varsOperands;
|
|
::llvm::SMLoc linear_varsOperandsLoc;
|
|
(void)linear_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> linear_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> linear_step_varsOperands;
|
|
::llvm::SMLoc linear_step_varsOperandsLoc;
|
|
(void)linear_step_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> linear_step_varsTypes;
|
|
::mlir::ArrayAttr linear_modifiersAttr;
|
|
::mlir::IntegerAttr simdlenAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> uniform_varsOperands;
|
|
::llvm::SMLoc uniform_varsOperandsLoc;
|
|
(void)uniform_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> uniform_varsTypes;
|
|
bool alignedClause = false;
|
|
bool inbranchClause = false;
|
|
bool linearClause = false;
|
|
bool notinbranchClause = false;
|
|
bool simdlenClause = false;
|
|
bool uniformClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("aligned"))) {
|
|
|
|
if (alignedClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`aligned` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
alignedClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
aligned_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseAlignedClause(parser, aligned_varsOperands, aligned_varsTypes, alignmentsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (alignmentsAttr)
|
|
result.getOrAddProperties<DeclareSimdOp::Properties>().alignments = alignmentsAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("inbranch"))) {
|
|
|
|
if (inbranchClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`inbranch` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
inbranchClause = true;
|
|
result.getOrAddProperties<DeclareSimdOp::Properties>().inbranch = parser.getBuilder().getUnitAttr(); } else if (succeeded(parser.parseOptionalKeyword("linear"))) {
|
|
|
|
if (linearClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`linear` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
linearClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
linear_varsOperandsLoc = parser.getCurrentLocation();
|
|
linear_step_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseLinearClause(parser, linear_varsOperands, linear_varsTypes, linear_step_varsOperands, linear_step_varsTypes, linear_modifiersAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (linear_modifiersAttr)
|
|
result.getOrAddProperties<DeclareSimdOp::Properties>().linear_modifiers = linear_modifiersAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("notinbranch"))) {
|
|
|
|
if (notinbranchClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`notinbranch` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
notinbranchClause = true;
|
|
result.getOrAddProperties<DeclareSimdOp::Properties>().notinbranch = parser.getBuilder().getUnitAttr(); } else if (succeeded(parser.parseOptionalKeyword("simdlen"))) {
|
|
|
|
if (simdlenClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`simdlen` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
simdlenClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
::mlir::OptionalParseResult parseResultsimdlenAttr =
|
|
parser.parseOptionalAttribute(simdlenAttr, parser.getBuilder().getIntegerType(64));
|
|
if (parseResultsimdlenAttr.has_value() && failed(*parseResultsimdlenAttr))
|
|
return ::mlir::failure();
|
|
if (parseResultsimdlenAttr.has_value() && succeeded(*parseResultsimdlenAttr))
|
|
if (simdlenAttr) result.getOrAddProperties<DeclareSimdOp::Properties>().simdlen = simdlenAttr;
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("uniform"))) {
|
|
|
|
if (uniformClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`uniform` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
uniformClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
uniform_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseUniformClause(parser, uniform_varsOperands, uniform_varsTypes);
|
|
if (odsResult) return ::mlir::failure();
|
|
}
|
|
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<int32_t>({static_cast<int32_t>(aligned_varsOperands.size()), static_cast<int32_t>(linear_varsOperands.size()), static_cast<int32_t>(linear_step_varsOperands.size()), static_cast<int32_t>(uniform_varsOperands.size())}), result.getOrAddProperties<DeclareSimdOp::Properties>().operandSegmentSizes.begin());
|
|
if (parser.resolveOperands(aligned_varsOperands, aligned_varsTypes, aligned_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(linear_varsOperands, linear_varsTypes, linear_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(linear_step_varsOperands, linear_step_varsTypes, linear_step_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(uniform_varsOperands, uniform_varsTypes, uniform_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void DeclareSimdOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getAlignedVars().size() || (getAlignmentsAttr())) {
|
|
_odsPrinter << ' ' << "aligned";
|
|
_odsPrinter << "(";
|
|
printAlignedClause(_odsPrinter, *this, getAlignedVars(), getAlignedVars().getTypes(), getAlignmentsAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getInbranchAttr() && getInbranchAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "inbranch";
|
|
}
|
|
if (false || getLinearVars().size() || getLinearStepVars().size() || (getLinearModifiersAttr())) {
|
|
_odsPrinter << ' ' << "linear";
|
|
_odsPrinter << "(";
|
|
printLinearClause(_odsPrinter, *this, getLinearVars(), getLinearVars().getTypes(), getLinearStepVars(), getLinearStepVars().getTypes(), getLinearModifiersAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getNotinbranchAttr() && getNotinbranchAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "notinbranch";
|
|
}
|
|
if (false || (getSimdlenAttr())) {
|
|
_odsPrinter << ' ' << "simdlen";
|
|
_odsPrinter << "(";
|
|
_odsPrinter.printAttributeWithoutType(getSimdlenAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getUniformVars().size()) {
|
|
_odsPrinter << ' ' << "uniform";
|
|
_odsPrinter << "(";
|
|
printUniformClause(_odsPrinter, *this, getUniformVars(), getUniformVars().getTypes());
|
|
_odsPrinter << ")";
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("alignments");
|
|
elidedAttrs.push_back("inbranch");
|
|
elidedAttrs.push_back("linear_modifiers");
|
|
elidedAttrs.push_back("notinbranch");
|
|
elidedAttrs.push_back("simdlen");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getInbranchAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("inbranch");
|
|
}
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getNotinbranchAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("notinbranch");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::DeclareSimdOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::DeclareSimdOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::DistributeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
DistributeOpGenericAdaptorBase::DistributeOpGenericAdaptorBase(DistributeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> DistributeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::UnitAttr DistributeOpGenericAdaptorBase::getDistScheduleStaticAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().dist_schedule_static);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool DistributeOpGenericAdaptorBase::getDistScheduleStatic() {
|
|
auto attr = getDistScheduleStaticAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseOrderKind> DistributeOpGenericAdaptorBase::getOrder() {
|
|
auto attr = getOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::OrderModifier> DistributeOpGenericAdaptorBase::getOrderMod() {
|
|
auto attr = getOrderModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::OrderModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > DistributeOpGenericAdaptorBase::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr DistributeOpGenericAdaptorBase::getPrivateNeedsBarrierAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().private_needs_barrier);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool DistributeOpGenericAdaptorBase::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
DistributeOpAdaptor::DistributeOpAdaptor(DistributeOp op) : DistributeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult DistributeOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_dist_schedule_static = getProperties().dist_schedule_static; (void)tblgen_dist_schedule_static;
|
|
auto tblgen_order = getProperties().order; (void)tblgen_order;
|
|
auto tblgen_order_mod = getProperties().order_mod; (void)tblgen_order_mod;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
|
|
if (tblgen_dist_schedule_static && !((::llvm::isa<::mlir::UnitAttr>(tblgen_dist_schedule_static))))
|
|
return emitError(loc, "'omp.distribute' op attribute 'dist_schedule_static' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_order && !((::llvm::isa<::mlir::omp::ClauseOrderKindAttr>(tblgen_order))))
|
|
return emitError(loc, "'omp.distribute' op attribute 'order' failed to satisfy constraint: OrderKind Clause");
|
|
|
|
if (tblgen_order_mod && !((::llvm::isa<::mlir::omp::OrderModifierAttr>(tblgen_order_mod))))
|
|
return emitError(loc, "'omp.distribute' op attribute 'order_mod' failed to satisfy constraint: OpenMP Order Modifier");
|
|
|
|
if (tblgen_private_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_private_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_private_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.distribute' op attribute 'private_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_private_needs_barrier && !((::llvm::isa<::mlir::UnitAttr>(tblgen_private_needs_barrier))))
|
|
return emitError(loc, "'omp.distribute' op attribute 'private_needs_barrier' failed to satisfy constraint: unit attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> DistributeOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange DistributeOp::getAllocateVarsMutable() {
|
|
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 DistributeOp::getAllocatorVarsMutable() {
|
|
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 DistributeOp::getDistScheduleChunkSizeMutable() {
|
|
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 DistributeOp::getPrivateVarsMutable() {
|
|
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 DistributeOp::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.dist_schedule_static;
|
|
auto attr = dict.get("dist_schedule_static");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `dist_schedule_static` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.order;
|
|
auto attr = dict.get("order");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `order` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.order_mod;
|
|
auto attr = dict.get("order_mod");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `order_mod` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_needs_barrier;
|
|
auto attr = dict.get("private_needs_barrier");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_needs_barrier` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_syms;
|
|
auto attr = dict.get("private_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_syms` 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 DistributeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.dist_schedule_static;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("dist_schedule_static",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.order;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("order",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.order_mod;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("order_mod",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_needs_barrier;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_needs_barrier",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_syms",
|
|
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 DistributeOp::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.dist_schedule_static.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.order.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.order_mod.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_needs_barrier.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_syms.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> DistributeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "dist_schedule_static")
|
|
return prop.dist_schedule_static;
|
|
|
|
if (name == "order")
|
|
return prop.order;
|
|
|
|
if (name == "order_mod")
|
|
return prop.order_mod;
|
|
|
|
if (name == "private_needs_barrier")
|
|
return prop.private_needs_barrier;
|
|
|
|
if (name == "private_syms")
|
|
return prop.private_syms;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void DistributeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "dist_schedule_static") {
|
|
prop.dist_schedule_static = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.dist_schedule_static)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "order") {
|
|
prop.order = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.order)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "order_mod") {
|
|
prop.order_mod = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.order_mod)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_needs_barrier") {
|
|
prop.private_needs_barrier = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_needs_barrier)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_syms") {
|
|
prop.private_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_syms)>>(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 DistributeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.dist_schedule_static) attrs.append("dist_schedule_static", prop.dist_schedule_static);
|
|
|
|
if (prop.order) attrs.append("order", prop.order);
|
|
|
|
if (prop.order_mod) attrs.append("order_mod", prop.order_mod);
|
|
|
|
if (prop.private_needs_barrier) attrs.append("private_needs_barrier", prop.private_needs_barrier);
|
|
|
|
if (prop.private_syms) attrs.append("private_syms", prop.private_syms);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult DistributeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDistScheduleStaticAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "dist_schedule_static", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getOrderAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps12(attr, "order", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getOrderModAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps13(attr, "order_mod", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateNeedsBarrierAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "private_needs_barrier", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "private_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DistributeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.dist_schedule_static)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.order)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.order_mod)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_needs_barrier)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_syms)))
|
|
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 DistributeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.dist_schedule_static);
|
|
|
|
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
|
|
}
|
|
|
|
writer.writeOptionalAttribute(prop.order);
|
|
|
|
writer.writeOptionalAttribute(prop.order_mod);
|
|
|
|
writer.writeOptionalAttribute(prop.private_needs_barrier);
|
|
|
|
writer.writeOptionalAttribute(prop.private_syms);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
bool DistributeOp::getDistScheduleStatic() {
|
|
auto attr = getDistScheduleStaticAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseOrderKind> DistributeOp::getOrder() {
|
|
auto attr = getOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::OrderModifier> DistributeOp::getOrderMod() {
|
|
auto attr = getOrderModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::OrderModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > DistributeOp::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool DistributeOp::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
void DistributeOp::setDistScheduleStatic(bool attrValue) {
|
|
auto &odsProp = getProperties().dist_schedule_static;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void DistributeOp::setOrder(::std::optional<::mlir::omp::ClauseOrderKind> attrValue) {
|
|
auto &odsProp = getProperties().order;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ClauseOrderKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void DistributeOp::setOrderMod(::std::optional<::mlir::omp::OrderModifier> attrValue) {
|
|
auto &odsProp = getProperties().order_mod;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::OrderModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void DistributeOp::setPrivateNeedsBarrier(bool attrValue) {
|
|
auto &odsProp = getProperties().private_needs_barrier;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
DistributeOp DistributeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const DistributeOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<DistributeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DistributeOp DistributeOp::create(::mlir::ImplicitLocOpBuilder &builder, const DistributeOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void DistributeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr dist_schedule_static, /*optional*/::mlir::Value dist_schedule_chunk_size, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
if (dist_schedule_chunk_size)
|
|
odsState.addOperands(dist_schedule_chunk_size);
|
|
odsState.addOperands(private_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), (dist_schedule_chunk_size ? 1 : 0), static_cast<int32_t>(private_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (dist_schedule_static) {
|
|
odsState.getOrAddProperties<Properties>().dist_schedule_static = dist_schedule_static;
|
|
}
|
|
if (order) {
|
|
odsState.getOrAddProperties<Properties>().order = order;
|
|
}
|
|
if (order_mod) {
|
|
odsState.getOrAddProperties<Properties>().order_mod = order_mod;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
DistributeOp DistributeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr dist_schedule_static, /*optional*/::mlir::Value dist_schedule_chunk_size, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(dist_schedule_static)>(dist_schedule_static), std::forward<decltype(dist_schedule_chunk_size)>(dist_schedule_chunk_size), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier));
|
|
auto __res__ = ::llvm::dyn_cast<DistributeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DistributeOp DistributeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr dist_schedule_static, /*optional*/::mlir::Value dist_schedule_chunk_size, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(dist_schedule_static)>(dist_schedule_static), std::forward<decltype(dist_schedule_chunk_size)>(dist_schedule_chunk_size), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier));
|
|
}
|
|
|
|
void DistributeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr dist_schedule_static, /*optional*/::mlir::Value dist_schedule_chunk_size, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
if (dist_schedule_chunk_size)
|
|
odsState.addOperands(dist_schedule_chunk_size);
|
|
odsState.addOperands(private_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), (dist_schedule_chunk_size ? 1 : 0), static_cast<int32_t>(private_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (dist_schedule_static) {
|
|
odsState.getOrAddProperties<Properties>().dist_schedule_static = dist_schedule_static;
|
|
}
|
|
if (order) {
|
|
odsState.getOrAddProperties<Properties>().order = order;
|
|
}
|
|
if (order_mod) {
|
|
odsState.getOrAddProperties<Properties>().order_mod = order_mod;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DistributeOp DistributeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr dist_schedule_static, /*optional*/::mlir::Value dist_schedule_chunk_size, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(dist_schedule_static)>(dist_schedule_static), std::forward<decltype(dist_schedule_chunk_size)>(dist_schedule_chunk_size), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier));
|
|
auto __res__ = ::llvm::dyn_cast<DistributeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DistributeOp DistributeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr dist_schedule_static, /*optional*/::mlir::Value dist_schedule_chunk_size, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(dist_schedule_static)>(dist_schedule_static), std::forward<decltype(dist_schedule_chunk_size)>(dist_schedule_chunk_size), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier));
|
|
}
|
|
|
|
void DistributeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool dist_schedule_static, /*optional*/::mlir::Value dist_schedule_chunk_size, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
if (dist_schedule_chunk_size)
|
|
odsState.addOperands(dist_schedule_chunk_size);
|
|
odsState.addOperands(private_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), (dist_schedule_chunk_size ? 1 : 0), static_cast<int32_t>(private_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (dist_schedule_static) {
|
|
odsState.getOrAddProperties<Properties>().dist_schedule_static = ((dist_schedule_static) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (order) {
|
|
odsState.getOrAddProperties<Properties>().order = order;
|
|
}
|
|
if (order_mod) {
|
|
odsState.getOrAddProperties<Properties>().order_mod = order_mod;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
DistributeOp DistributeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool dist_schedule_static, /*optional*/::mlir::Value dist_schedule_chunk_size, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(dist_schedule_static)>(dist_schedule_static), std::forward<decltype(dist_schedule_chunk_size)>(dist_schedule_chunk_size), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier));
|
|
auto __res__ = ::llvm::dyn_cast<DistributeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DistributeOp DistributeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool dist_schedule_static, /*optional*/::mlir::Value dist_schedule_chunk_size, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(dist_schedule_static)>(dist_schedule_static), std::forward<decltype(dist_schedule_chunk_size)>(dist_schedule_chunk_size), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier));
|
|
}
|
|
|
|
void DistributeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool dist_schedule_static, /*optional*/::mlir::Value dist_schedule_chunk_size, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
if (dist_schedule_chunk_size)
|
|
odsState.addOperands(dist_schedule_chunk_size);
|
|
odsState.addOperands(private_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), (dist_schedule_chunk_size ? 1 : 0), static_cast<int32_t>(private_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (dist_schedule_static) {
|
|
odsState.getOrAddProperties<Properties>().dist_schedule_static = ((dist_schedule_static) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (order) {
|
|
odsState.getOrAddProperties<Properties>().order = order;
|
|
}
|
|
if (order_mod) {
|
|
odsState.getOrAddProperties<Properties>().order_mod = order_mod;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DistributeOp DistributeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool dist_schedule_static, /*optional*/::mlir::Value dist_schedule_chunk_size, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(dist_schedule_static)>(dist_schedule_static), std::forward<decltype(dist_schedule_chunk_size)>(dist_schedule_chunk_size), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier));
|
|
auto __res__ = ::llvm::dyn_cast<DistributeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DistributeOp DistributeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool dist_schedule_static, /*optional*/::mlir::Value dist_schedule_chunk_size, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(dist_schedule_static)>(dist_schedule_static), std::forward<decltype(dist_schedule_chunk_size)>(dist_schedule_chunk_size), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier));
|
|
}
|
|
|
|
void DistributeOp::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<DistributeOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
DistributeOp DistributeOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<DistributeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DistributeOp DistributeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void DistributeOp::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&>(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);
|
|
}
|
|
|
|
DistributeOp DistributeOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<DistributeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DistributeOp DistributeOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult DistributeOp::verifyInvariantsImpl() {
|
|
auto tblgen_dist_schedule_static = getProperties().dist_schedule_static; (void)tblgen_dist_schedule_static;
|
|
auto tblgen_order = getProperties().order; (void)tblgen_order;
|
|
auto tblgen_order_mod = getProperties().order_mod; (void)tblgen_order_mod;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_dist_schedule_static, "dist_schedule_static")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps12(*this, tblgen_order, "order")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps13(*this, tblgen_order_mod, "order_mod")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_private_syms, "private_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_private_needs_barrier, "private_needs_barrier")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*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_OpenMPOps2(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*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_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DistributeOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult DistributeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocate_varsOperands;
|
|
::llvm::SMLoc allocate_varsOperandsLoc;
|
|
(void)allocate_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocate_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocator_varsOperands;
|
|
::llvm::SMLoc allocator_varsOperandsLoc;
|
|
(void)allocator_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocator_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dist_schedule_chunk_sizeOperands;
|
|
::llvm::SMLoc dist_schedule_chunk_sizeOperandsLoc;
|
|
(void)dist_schedule_chunk_sizeOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> dist_schedule_chunk_sizeTypes;
|
|
::mlir::omp::ClauseOrderKindAttr orderAttr;
|
|
::mlir::omp::OrderModifierAttr order_modAttr;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> private_varsOperands;
|
|
::llvm::SMLoc private_varsOperandsLoc;
|
|
(void)private_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> private_varsTypes;
|
|
::mlir::ArrayAttr private_symsAttr;
|
|
::mlir::UnitAttr private_needs_barrierAttr;
|
|
bool allocateClause = false;
|
|
bool dist_schedule_staticClause = false;
|
|
bool dist_schedule_chunk_sizeClause = false;
|
|
bool orderClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("allocate"))) {
|
|
|
|
if (allocateClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`allocate` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
allocateClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
allocate_varsOperandsLoc = parser.getCurrentLocation();
|
|
allocator_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseAllocateAndAllocator(parser, allocate_varsOperands, allocate_varsTypes, allocator_varsOperands, allocator_varsTypes);
|
|
if (odsResult) return ::mlir::failure();
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("dist_schedule_static"))) {
|
|
|
|
if (dist_schedule_staticClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`dist_schedule_static` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
dist_schedule_staticClause = true;
|
|
result.getOrAddProperties<DistributeOp::Properties>().dist_schedule_static = parser.getBuilder().getUnitAttr(); } else if (succeeded(parser.parseOptionalKeyword("dist_schedule_chunk_size"))) {
|
|
|
|
if (dist_schedule_chunk_sizeClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`dist_schedule_chunk_size` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
dist_schedule_chunk_sizeClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
dist_schedule_chunk_sizeOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
dist_schedule_chunk_sizeOperands.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();
|
|
dist_schedule_chunk_sizeTypes.push_back(optionalType);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("order"))) {
|
|
|
|
if (orderClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`order` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
orderClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseOrderClause(parser, orderAttr, order_modAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (orderAttr)
|
|
result.getOrAddProperties<DistributeOp::Properties>().order = orderAttr;
|
|
if (order_modAttr)
|
|
result.getOrAddProperties<DistributeOp::Properties>().order_mod = order_modAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
{
|
|
private_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parsePrivateRegion(parser, *regionRegion, private_varsOperands, private_varsTypes, private_symsAttr, private_needs_barrierAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (private_symsAttr)
|
|
result.getOrAddProperties<DistributeOp::Properties>().private_syms = private_symsAttr;
|
|
if (private_needs_barrierAttr)
|
|
result.getOrAddProperties<DistributeOp::Properties>().private_needs_barrier = private_needs_barrierAttr;
|
|
}
|
|
{
|
|
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<int32_t>({static_cast<int32_t>(allocate_varsOperands.size()), static_cast<int32_t>(allocator_varsOperands.size()), static_cast<int32_t>(dist_schedule_chunk_sizeOperands.size()), static_cast<int32_t>(private_varsOperands.size())}), result.getOrAddProperties<DistributeOp::Properties>().operandSegmentSizes.begin());
|
|
if (parser.resolveOperands(allocate_varsOperands, allocate_varsTypes, allocate_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(allocator_varsOperands, allocator_varsTypes, allocator_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!dist_schedule_chunk_sizeOperands.empty()) {
|
|
if (parser.resolveOperands(dist_schedule_chunk_sizeOperands, dist_schedule_chunk_sizeTypes, dist_schedule_chunk_sizeOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(private_varsOperands, private_varsTypes, private_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void DistributeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getAllocateVars().size() || getAllocatorVars().size()) {
|
|
_odsPrinter << ' ' << "allocate";
|
|
_odsPrinter << "(";
|
|
printAllocateAndAllocator(_odsPrinter, *this, getAllocateVars(), getAllocateVars().getTypes(), getAllocatorVars(), getAllocatorVars().getTypes());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getDistScheduleStaticAttr() && getDistScheduleStaticAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "dist_schedule_static";
|
|
}
|
|
if (false || getDistScheduleChunkSize()) {
|
|
_odsPrinter << ' ' << "dist_schedule_chunk_size";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getDistScheduleChunkSize())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << (getDistScheduleChunkSize() ? ::llvm::ArrayRef<::mlir::Type>(getDistScheduleChunkSize().getType()) : ::llvm::ArrayRef<::mlir::Type>());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getOrderAttr()) || (getOrderModAttr())) {
|
|
_odsPrinter << ' ' << "order";
|
|
_odsPrinter << "(";
|
|
printOrderClause(_odsPrinter, *this, getOrderAttr(), getOrderModAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ';
|
|
printPrivateRegion(_odsPrinter, *this, getRegion(), getPrivateVars(), getPrivateVars().getTypes(), getPrivateSymsAttr(), getPrivateNeedsBarrierAttr());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("dist_schedule_static");
|
|
elidedAttrs.push_back("order");
|
|
elidedAttrs.push_back("order_mod");
|
|
elidedAttrs.push_back("private_syms");
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getDistScheduleStaticAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("dist_schedule_static");
|
|
}
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getPrivateNeedsBarrierAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::DistributeOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::DistributeOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::FlushOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
FlushOpGenericAdaptorBase::FlushOpGenericAdaptorBase(FlushOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> FlushOpGenericAdaptorBase::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
|
|
FlushOpAdaptor::FlushOpAdaptor(FlushOp op) : FlushOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult FlushOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> FlushOp::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 FlushOp::getVarListMutable() {
|
|
auto range = getODSOperandIndexAndLength(0);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
|
|
return mutableRange;
|
|
}
|
|
|
|
::llvm::LogicalResult FlushOp::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 FlushOp::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 FlushOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> FlushOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void FlushOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void FlushOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult FlushOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void FlushOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange varList) {
|
|
odsState.addOperands(varList);
|
|
}
|
|
|
|
FlushOp FlushOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange varList) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(varList)>(varList));
|
|
auto __res__ = ::llvm::dyn_cast<FlushOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FlushOp FlushOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange varList) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(varList)>(varList));
|
|
}
|
|
|
|
void FlushOp::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);
|
|
}
|
|
|
|
FlushOp FlushOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<FlushOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FlushOp FlushOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void FlushOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
FlushOp FlushOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<FlushOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FlushOp FlushOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult FlushOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult FlushOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult FlushOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varListOperands;
|
|
::llvm::SMLoc varListOperandsLoc;
|
|
(void)varListOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> varListTypes;
|
|
if (::mlir::succeeded(parser.parseOptionalLParen())) {
|
|
|
|
varListOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(varListOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(varListTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
}
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
|
|
return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
|
|
})))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(varListOperands, varListTypes, varListOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void FlushOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (!getVarList().empty()) {
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getVarList();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getVarList().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::FlushOp)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::FreeSharedMemOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
FreeSharedMemOpGenericAdaptorBase::FreeSharedMemOpGenericAdaptorBase(FreeSharedMemOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::Type FreeSharedMemOpGenericAdaptorBase::getMemElemType() {
|
|
auto attr = getMemElemTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::std::optional<uint64_t> FreeSharedMemOpGenericAdaptorBase::getMemAlignment() {
|
|
auto attr = getMemAlignmentAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
FreeSharedMemOpAdaptor::FreeSharedMemOpAdaptor(FreeSharedMemOp op) : FreeSharedMemOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult FreeSharedMemOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_mem_alignment = getProperties().mem_alignment; (void)tblgen_mem_alignment;
|
|
auto tblgen_mem_elem_type = getProperties().mem_elem_type; (void)tblgen_mem_elem_type;
|
|
if (!tblgen_mem_elem_type) return emitError(loc, "'omp.free_shared_mem' op requires attribute 'mem_elem_type'");
|
|
|
|
if (tblgen_mem_elem_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_mem_elem_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_mem_elem_type).getValue()))) && ((true))))
|
|
return emitError(loc, "'omp.free_shared_mem' op attribute 'mem_elem_type' failed to satisfy constraint: any type attribute");
|
|
|
|
if (tblgen_mem_alignment && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_mem_alignment))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_mem_alignment).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_mem_alignment).getValue().isStrictlyPositive()))))
|
|
return emitError(loc, "'omp.free_shared_mem' op attribute 'mem_alignment' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult FreeSharedMemOp::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.mem_alignment;
|
|
auto attr = dict.get("mem_alignment");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `mem_alignment` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.mem_elem_type;
|
|
auto attr = dict.get("mem_elem_type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `mem_elem_type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute FreeSharedMemOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.mem_alignment;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("mem_alignment",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.mem_elem_type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("mem_elem_type",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code FreeSharedMemOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.mem_alignment.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.mem_elem_type.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> FreeSharedMemOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "mem_alignment")
|
|
return prop.mem_alignment;
|
|
|
|
if (name == "mem_elem_type")
|
|
return prop.mem_elem_type;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void FreeSharedMemOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "mem_alignment") {
|
|
prop.mem_alignment = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.mem_alignment)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "mem_elem_type") {
|
|
prop.mem_elem_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.mem_elem_type)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void FreeSharedMemOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.mem_alignment) attrs.append("mem_alignment", prop.mem_alignment);
|
|
|
|
if (prop.mem_elem_type) attrs.append("mem_elem_type", prop.mem_elem_type);
|
|
}
|
|
|
|
::llvm::LogicalResult FreeSharedMemOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMemAlignmentAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps2(attr, "mem_alignment", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMemElemTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(attr, "mem_elem_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult FreeSharedMemOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.mem_alignment)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.mem_elem_type)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void FreeSharedMemOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.mem_alignment);
|
|
writer.writeAttribute(prop.mem_elem_type);
|
|
}
|
|
|
|
::mlir::Type FreeSharedMemOp::getMemElemType() {
|
|
auto attr = getMemElemTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::std::optional<uint64_t> FreeSharedMemOp::getMemAlignment() {
|
|
auto attr = getMemAlignmentAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
void FreeSharedMemOp::setMemElemType(::mlir::Type attrValue) {
|
|
getProperties().mem_elem_type = ::mlir::TypeAttr::get(attrValue);
|
|
}
|
|
|
|
void FreeSharedMemOp::setMemAlignment(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().mem_alignment;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void FreeSharedMemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeAttr mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment, ::mlir::Value heapref) {
|
|
odsState.addOperands(mem_array_size);
|
|
odsState.addOperands(heapref);
|
|
odsState.getOrAddProperties<Properties>().mem_elem_type = mem_elem_type;
|
|
if (mem_alignment) {
|
|
odsState.getOrAddProperties<Properties>().mem_alignment = mem_alignment;
|
|
}
|
|
}
|
|
|
|
FreeSharedMemOp FreeSharedMemOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeAttr mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment, ::mlir::Value heapref) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(mem_elem_type)>(mem_elem_type), std::forward<decltype(mem_array_size)>(mem_array_size), std::forward<decltype(mem_alignment)>(mem_alignment), std::forward<decltype(heapref)>(heapref));
|
|
auto __res__ = ::llvm::dyn_cast<FreeSharedMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FreeSharedMemOp FreeSharedMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeAttr mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment, ::mlir::Value heapref) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(mem_elem_type)>(mem_elem_type), std::forward<decltype(mem_array_size)>(mem_array_size), std::forward<decltype(mem_alignment)>(mem_alignment), std::forward<decltype(heapref)>(heapref));
|
|
}
|
|
|
|
void FreeSharedMemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::TypeAttr mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment, ::mlir::Value heapref) {
|
|
odsState.addOperands(mem_array_size);
|
|
odsState.addOperands(heapref);
|
|
odsState.getOrAddProperties<Properties>().mem_elem_type = mem_elem_type;
|
|
if (mem_alignment) {
|
|
odsState.getOrAddProperties<Properties>().mem_alignment = mem_alignment;
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
FreeSharedMemOp FreeSharedMemOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::TypeAttr mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment, ::mlir::Value heapref) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(mem_elem_type)>(mem_elem_type), std::forward<decltype(mem_array_size)>(mem_array_size), std::forward<decltype(mem_alignment)>(mem_alignment), std::forward<decltype(heapref)>(heapref));
|
|
auto __res__ = ::llvm::dyn_cast<FreeSharedMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FreeSharedMemOp FreeSharedMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::TypeAttr mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment, ::mlir::Value heapref) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(mem_elem_type)>(mem_elem_type), std::forward<decltype(mem_array_size)>(mem_array_size), std::forward<decltype(mem_alignment)>(mem_alignment), std::forward<decltype(heapref)>(heapref));
|
|
}
|
|
|
|
void FreeSharedMemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment, ::mlir::Value heapref) {
|
|
odsState.addOperands(mem_array_size);
|
|
odsState.addOperands(heapref);
|
|
odsState.getOrAddProperties<Properties>().mem_elem_type = ::mlir::TypeAttr::get(mem_elem_type);
|
|
if (mem_alignment) {
|
|
odsState.getOrAddProperties<Properties>().mem_alignment = mem_alignment;
|
|
}
|
|
}
|
|
|
|
FreeSharedMemOp FreeSharedMemOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment, ::mlir::Value heapref) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(mem_elem_type)>(mem_elem_type), std::forward<decltype(mem_array_size)>(mem_array_size), std::forward<decltype(mem_alignment)>(mem_alignment), std::forward<decltype(heapref)>(heapref));
|
|
auto __res__ = ::llvm::dyn_cast<FreeSharedMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FreeSharedMemOp FreeSharedMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment, ::mlir::Value heapref) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(mem_elem_type)>(mem_elem_type), std::forward<decltype(mem_array_size)>(mem_array_size), std::forward<decltype(mem_alignment)>(mem_alignment), std::forward<decltype(heapref)>(heapref));
|
|
}
|
|
|
|
void FreeSharedMemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Type mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment, ::mlir::Value heapref) {
|
|
odsState.addOperands(mem_array_size);
|
|
odsState.addOperands(heapref);
|
|
odsState.getOrAddProperties<Properties>().mem_elem_type = ::mlir::TypeAttr::get(mem_elem_type);
|
|
if (mem_alignment) {
|
|
odsState.getOrAddProperties<Properties>().mem_alignment = mem_alignment;
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
FreeSharedMemOp FreeSharedMemOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Type mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment, ::mlir::Value heapref) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(mem_elem_type)>(mem_elem_type), std::forward<decltype(mem_array_size)>(mem_array_size), std::forward<decltype(mem_alignment)>(mem_alignment), std::forward<decltype(heapref)>(heapref));
|
|
auto __res__ = ::llvm::dyn_cast<FreeSharedMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FreeSharedMemOp FreeSharedMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Type mem_elem_type, ::mlir::Value mem_array_size, /*optional*/::mlir::IntegerAttr mem_alignment, ::mlir::Value heapref) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(mem_elem_type)>(mem_elem_type), std::forward<decltype(mem_array_size)>(mem_array_size), std::forward<decltype(mem_alignment)>(mem_alignment), std::forward<decltype(heapref)>(heapref));
|
|
}
|
|
|
|
void FreeSharedMemOp::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<FreeSharedMemOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
FreeSharedMemOp FreeSharedMemOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<FreeSharedMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FreeSharedMemOp FreeSharedMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void FreeSharedMemOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
FreeSharedMemOp FreeSharedMemOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<FreeSharedMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FreeSharedMemOp FreeSharedMemOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult FreeSharedMemOp::verifyInvariantsImpl() {
|
|
auto tblgen_mem_alignment = getProperties().mem_alignment; (void)tblgen_mem_alignment;
|
|
auto tblgen_mem_elem_type = getProperties().mem_elem_type; (void)tblgen_mem_elem_type;
|
|
if (!tblgen_mem_elem_type) return emitOpError("requires attribute 'mem_elem_type'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(*this, tblgen_mem_elem_type, "mem_elem_type")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps2(*this, tblgen_mem_alignment, "mem_alignment")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps4(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult FreeSharedMemOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult FreeSharedMemOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::OpAsmParser::UnresolvedOperand mem_array_sizeRawOperand{};
|
|
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> mem_array_sizeOperands(&mem_array_sizeRawOperand, 1); ::llvm::SMLoc mem_array_sizeOperandsLoc;
|
|
(void)mem_array_sizeOperandsLoc;
|
|
::mlir::TypeAttr mem_elem_typeAttr;
|
|
::mlir::Type mem_array_sizeRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> mem_array_sizeTypes(&mem_array_sizeRawType, 1);
|
|
::mlir::IntegerAttr mem_alignmentAttr;
|
|
::mlir::OpAsmParser::UnresolvedOperand heaprefRawOperand{};
|
|
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> heaprefOperands(&heaprefRawOperand, 1); ::llvm::SMLoc heaprefOperandsLoc;
|
|
(void)heaprefOperandsLoc;
|
|
::mlir::Type heaprefRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> heaprefTypes(&heaprefRawType, 1);
|
|
if (parser.parseLSquare())
|
|
return ::mlir::failure();
|
|
|
|
mem_array_sizeOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperand(mem_array_sizeRawOperand))
|
|
return ::mlir::failure();
|
|
if (parser.parseKeyword("x"))
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseCustomAttributeWithFallback(mem_elem_typeAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
|
|
return ::mlir::failure();
|
|
}
|
|
if (mem_elem_typeAttr) result.getOrAddProperties<FreeSharedMemOp::Properties>().mem_elem_type = mem_elem_typeAttr;
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
::mlir::IntegerType type;
|
|
if (parser.parseCustomTypeWithFallback(type))
|
|
return ::mlir::failure();
|
|
mem_array_sizeRawType = type;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
bool alignClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("align"))) {
|
|
|
|
if (alignClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`align` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
alignClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
::mlir::OptionalParseResult parseResultmem_alignmentAttr =
|
|
parser.parseOptionalAttribute(mem_alignmentAttr, parser.getBuilder().getIntegerType(64));
|
|
if (parseResultmem_alignmentAttr.has_value() && failed(*parseResultmem_alignmentAttr))
|
|
return ::mlir::failure();
|
|
if (parseResultmem_alignmentAttr.has_value() && succeeded(*parseResultmem_alignmentAttr))
|
|
if (mem_alignmentAttr) result.getOrAddProperties<FreeSharedMemOp::Properties>().mem_alignment = mem_alignmentAttr;
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
if (parser.parseRSquare())
|
|
return ::mlir::failure();
|
|
|
|
heaprefOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperand(heaprefRawOperand))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
::mlir::omp::PointerLikeType type;
|
|
if (parser.parseCustomTypeWithFallback(type))
|
|
return ::mlir::failure();
|
|
heaprefRawType = 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(mem_array_sizeOperands, mem_array_sizeTypes, mem_array_sizeOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(heaprefOperands, heaprefTypes, heaprefOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void FreeSharedMemOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << "[";
|
|
_odsPrinter << getMemArraySize();
|
|
_odsPrinter << ' ' << "x";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printAttributeWithoutType(getMemElemTypeAttr());
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ' << "(";
|
|
{
|
|
auto type = getMemArraySize().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type))
|
|
_odsPrinter.printStrippedAttrOrType(validType);
|
|
else
|
|
_odsPrinter << type;
|
|
}
|
|
_odsPrinter << ")";
|
|
if (false || (getMemAlignmentAttr())) {
|
|
_odsPrinter << ' ' << "align";
|
|
_odsPrinter << "(";
|
|
_odsPrinter.printAttributeWithoutType(getMemAlignmentAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << "]";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getHeapref();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
{
|
|
auto type = getHeapref().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::omp::PointerLikeType>(type))
|
|
_odsPrinter.printStrippedAttrOrType(validType);
|
|
else
|
|
_odsPrinter << type;
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("mem_elem_type");
|
|
elidedAttrs.push_back("mem_alignment");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
void FreeSharedMemOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
effects.emplace_back(::mlir::MemoryEffects::Free::get(), 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::Free::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get());
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::FreeSharedMemOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::FreeSharedMemOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::FuseOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
FuseOpGenericAdaptorBase::FuseOpGenericAdaptorBase(FuseOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> FuseOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::std::optional<uint64_t> FuseOpGenericAdaptorBase::getFirst() {
|
|
auto attr = getFirstAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<uint64_t> FuseOpGenericAdaptorBase::getCount() {
|
|
auto attr = getCountAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
FuseOpAdaptor::FuseOpAdaptor(FuseOp op) : FuseOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult FuseOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_count = getProperties().count; (void)tblgen_count;
|
|
auto tblgen_first = getProperties().first; (void)tblgen_first;
|
|
|
|
if (tblgen_first && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_first))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_first).getType().isSignlessInteger(64)))))
|
|
return emitError(loc, "'omp.fuse' op attribute 'first' failed to satisfy constraint: 64-bit signless integer attribute");
|
|
|
|
if (tblgen_count && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_count))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_count).getType().isSignlessInteger(64)))))
|
|
return emitError(loc, "'omp.fuse' op attribute 'count' failed to satisfy constraint: 64-bit signless integer attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> FuseOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange FuseOp::getGenerateesMutable() {
|
|
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 FuseOp::getApplyeesMutable() {
|
|
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 FuseOp::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.count;
|
|
auto attr = dict.get("count");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `count` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.first;
|
|
auto attr = dict.get("first");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `first` 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 FuseOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.count;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("count",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.first;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("first",
|
|
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 FuseOp::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.count.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.first.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> FuseOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "count")
|
|
return prop.count;
|
|
|
|
if (name == "first")
|
|
return prop.first;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void FuseOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "count") {
|
|
prop.count = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.count)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "first") {
|
|
prop.first = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.first)>>(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 FuseOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.count) attrs.append("count", prop.count);
|
|
|
|
if (prop.first) attrs.append("first", prop.first);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult FuseOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getCountAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps3(attr, "count", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getFirstAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps3(attr, "first", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult FuseOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.count)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.first)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(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 FuseOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.count);
|
|
|
|
writer.writeOptionalAttribute(prop.first);
|
|
|
|
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<uint64_t> FuseOp::getFirst() {
|
|
auto attr = getFirstAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<uint64_t> FuseOp::getCount() {
|
|
auto attr = getCountAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
void FuseOp::setFirst(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().first;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void FuseOp::setCount(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().count;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void FuseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange generatees, ::mlir::ValueRange applyees, /*optional*/::mlir::IntegerAttr first, /*optional*/::mlir::IntegerAttr count) {
|
|
odsState.addOperands(generatees);
|
|
odsState.addOperands(applyees);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(generatees.size()), static_cast<int32_t>(applyees.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (first) {
|
|
odsState.getOrAddProperties<Properties>().first = first;
|
|
}
|
|
if (count) {
|
|
odsState.getOrAddProperties<Properties>().count = count;
|
|
}
|
|
}
|
|
|
|
FuseOp FuseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange generatees, ::mlir::ValueRange applyees, /*optional*/::mlir::IntegerAttr first, /*optional*/::mlir::IntegerAttr count) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(generatees)>(generatees), std::forward<decltype(applyees)>(applyees), std::forward<decltype(first)>(first), std::forward<decltype(count)>(count));
|
|
auto __res__ = ::llvm::dyn_cast<FuseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FuseOp FuseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange generatees, ::mlir::ValueRange applyees, /*optional*/::mlir::IntegerAttr first, /*optional*/::mlir::IntegerAttr count) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(generatees)>(generatees), std::forward<decltype(applyees)>(applyees), std::forward<decltype(first)>(first), std::forward<decltype(count)>(count));
|
|
}
|
|
|
|
void FuseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange generatees, ::mlir::ValueRange applyees, /*optional*/::mlir::IntegerAttr first, /*optional*/::mlir::IntegerAttr count) {
|
|
odsState.addOperands(generatees);
|
|
odsState.addOperands(applyees);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(generatees.size()), static_cast<int32_t>(applyees.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (first) {
|
|
odsState.getOrAddProperties<Properties>().first = first;
|
|
}
|
|
if (count) {
|
|
odsState.getOrAddProperties<Properties>().count = count;
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
FuseOp FuseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange generatees, ::mlir::ValueRange applyees, /*optional*/::mlir::IntegerAttr first, /*optional*/::mlir::IntegerAttr count) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(generatees)>(generatees), std::forward<decltype(applyees)>(applyees), std::forward<decltype(first)>(first), std::forward<decltype(count)>(count));
|
|
auto __res__ = ::llvm::dyn_cast<FuseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FuseOp FuseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange generatees, ::mlir::ValueRange applyees, /*optional*/::mlir::IntegerAttr first, /*optional*/::mlir::IntegerAttr count) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(generatees)>(generatees), std::forward<decltype(applyees)>(applyees), std::forward<decltype(first)>(first), std::forward<decltype(count)>(count));
|
|
}
|
|
|
|
void FuseOp::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<FuseOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
FuseOp FuseOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<FuseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FuseOp FuseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void FuseOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
FuseOp FuseOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<FuseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FuseOp FuseOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult FuseOp::verifyInvariantsImpl() {
|
|
auto tblgen_count = getProperties().count; (void)tblgen_count;
|
|
auto tblgen_first = getProperties().first; (void)tblgen_first;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps3(*this, tblgen_first, "first")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps3(*this, tblgen_count, "count")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps13(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps13(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult FuseOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult FuseOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> generateesOperands;
|
|
::llvm::SMLoc generateesOperandsLoc;
|
|
(void)generateesOperandsLoc;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> applyeesOperands;
|
|
::llvm::SMLoc applyeesOperandsLoc;
|
|
(void)applyeesOperandsLoc;
|
|
::mlir::IntegerAttr firstAttr;
|
|
::mlir::IntegerAttr countAttr;
|
|
{
|
|
generateesOperandsLoc = parser.getCurrentLocation();
|
|
applyeesOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseLoopTransformClis(parser, generateesOperands, applyeesOperands);
|
|
if (odsResult) return ::mlir::failure();
|
|
}
|
|
bool looprangeClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("looprange"))) {
|
|
|
|
if (looprangeClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`looprange` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
looprangeClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
if (parser.parseKeyword("first"))
|
|
return ::mlir::failure();
|
|
if (parser.parseEqual())
|
|
return ::mlir::failure();
|
|
|
|
::mlir::OptionalParseResult parseResultfirstAttr =
|
|
parser.parseOptionalAttribute(firstAttr, parser.getBuilder().getIntegerType(64));
|
|
if (parseResultfirstAttr.has_value() && failed(*parseResultfirstAttr))
|
|
return ::mlir::failure();
|
|
if (parseResultfirstAttr.has_value() && succeeded(*parseResultfirstAttr))
|
|
if (firstAttr) result.getOrAddProperties<FuseOp::Properties>().first = firstAttr;
|
|
if (parser.parseComma())
|
|
return ::mlir::failure();
|
|
if (parser.parseKeyword("count"))
|
|
return ::mlir::failure();
|
|
if (parser.parseEqual())
|
|
return ::mlir::failure();
|
|
|
|
::mlir::OptionalParseResult parseResultcountAttr =
|
|
parser.parseOptionalAttribute(countAttr, parser.getBuilder().getIntegerType(64));
|
|
if (parseResultcountAttr.has_value() && failed(*parseResultcountAttr))
|
|
return ::mlir::failure();
|
|
if (parseResultcountAttr.has_value() && succeeded(*parseResultcountAttr))
|
|
if (countAttr) result.getOrAddProperties<FuseOp::Properties>().count = countAttr;
|
|
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<int32_t>({static_cast<int32_t>(generateesOperands.size()), static_cast<int32_t>(applyeesOperands.size())}), result.getOrAddProperties<FuseOp::Properties>().operandSegmentSizes.begin());
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::omp::CanonicalLoopInfoType>();
|
|
if (parser.resolveOperands(generateesOperands, odsBuildableType0, generateesOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(applyeesOperands, odsBuildableType0, applyeesOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void FuseOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
printLoopTransformClis(_odsPrinter, *this, getGeneratees(), getApplyees());
|
|
if (false || (getFirstAttr()) || (getCountAttr())) {
|
|
_odsPrinter << ' ' << "looprange";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << "first";
|
|
_odsPrinter << ' ' << "=";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printAttributeWithoutType(getFirstAttr());
|
|
_odsPrinter << ",";
|
|
_odsPrinter << ' ' << "count";
|
|
_odsPrinter << ' ' << "=";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printAttributeWithoutType(getCountAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("first");
|
|
elidedAttrs.push_back("count");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::FuseOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::FuseOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::GroupprivateOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
GroupprivateOpGenericAdaptorBase::GroupprivateOpGenericAdaptorBase(GroupprivateOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::llvm::StringRef GroupprivateOpGenericAdaptorBase::getSymName() {
|
|
auto attr = getSymNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::std::optional<::mlir::omp::DeclareTargetDeviceType> GroupprivateOpGenericAdaptorBase::getDeviceType() {
|
|
auto attr = getDeviceTypeAttr();
|
|
return attr ? ::std::optional<::mlir::omp::DeclareTargetDeviceType>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
GroupprivateOpAdaptor::GroupprivateOpAdaptor(GroupprivateOp op) : GroupprivateOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult GroupprivateOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_device_type = getProperties().device_type; (void)tblgen_device_type;
|
|
auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
|
|
if (!tblgen_sym_name) return emitError(loc, "'omp.groupprivate' op requires attribute 'sym_name'");
|
|
|
|
if (tblgen_sym_name && !((::llvm::isa<::mlir::FlatSymbolRefAttr>(tblgen_sym_name))))
|
|
return emitError(loc, "'omp.groupprivate' op attribute 'sym_name' failed to satisfy constraint: flat symbol reference attribute");
|
|
|
|
if (tblgen_device_type && !((::llvm::isa<::mlir::omp::DeclareTargetDeviceTypeAttr>(tblgen_device_type))))
|
|
return emitError(loc, "'omp.groupprivate' op attribute 'device_type' failed to satisfy constraint: device_type clause");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult GroupprivateOp::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<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `device_type` 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<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `sym_name` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute GroupprivateOp::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.sym_name;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("sym_name",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code GroupprivateOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.device_type.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.sym_name.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> GroupprivateOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "device_type")
|
|
return prop.device_type;
|
|
|
|
if (name == "sym_name")
|
|
return prop.sym_name;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void GroupprivateOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "device_type") {
|
|
prop.device_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.device_type)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "sym_name") {
|
|
prop.sym_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.sym_name)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void GroupprivateOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.device_type) attrs.append("device_type", prop.device_type);
|
|
|
|
if (prop.sym_name) attrs.append("sym_name", prop.sym_name);
|
|
}
|
|
|
|
::llvm::LogicalResult GroupprivateOp::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_OpenMPOps15(attr, "device_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps9(attr, "sym_name", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult GroupprivateOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.device_type)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.sym_name)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void GroupprivateOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.device_type);
|
|
writer.writeAttribute(prop.sym_name);
|
|
}
|
|
|
|
::llvm::StringRef GroupprivateOp::getSymName() {
|
|
auto attr = getSymNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::std::optional<::mlir::omp::DeclareTargetDeviceType> GroupprivateOp::getDeviceType() {
|
|
auto attr = getDeviceTypeAttr();
|
|
return attr ? ::std::optional<::mlir::omp::DeclareTargetDeviceType>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
void GroupprivateOp::setSymName(::llvm::StringRef attrValue) {
|
|
getProperties().sym_name = ::mlir::SymbolRefAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void GroupprivateOp::setDeviceType(::std::optional<::mlir::omp::DeclareTargetDeviceType> attrValue) {
|
|
auto &odsProp = getProperties().device_type;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::DeclareTargetDeviceTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void GroupprivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type gp_addr, ::mlir::FlatSymbolRefAttr sym_name, /*optional*/::mlir::omp::DeclareTargetDeviceTypeAttr device_type) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = sym_name;
|
|
if (device_type) {
|
|
odsState.getOrAddProperties<Properties>().device_type = device_type;
|
|
}
|
|
odsState.addTypes(gp_addr);
|
|
}
|
|
|
|
GroupprivateOp GroupprivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type gp_addr, ::mlir::FlatSymbolRefAttr sym_name, /*optional*/::mlir::omp::DeclareTargetDeviceTypeAttr device_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(gp_addr)>(gp_addr), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(device_type)>(device_type));
|
|
auto __res__ = ::llvm::dyn_cast<GroupprivateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GroupprivateOp GroupprivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type gp_addr, ::mlir::FlatSymbolRefAttr sym_name, /*optional*/::mlir::omp::DeclareTargetDeviceTypeAttr device_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(gp_addr)>(gp_addr), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(device_type)>(device_type));
|
|
}
|
|
|
|
void GroupprivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::FlatSymbolRefAttr sym_name, /*optional*/::mlir::omp::DeclareTargetDeviceTypeAttr device_type) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = sym_name;
|
|
if (device_type) {
|
|
odsState.getOrAddProperties<Properties>().device_type = device_type;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
GroupprivateOp GroupprivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::FlatSymbolRefAttr sym_name, /*optional*/::mlir::omp::DeclareTargetDeviceTypeAttr device_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(device_type)>(device_type));
|
|
auto __res__ = ::llvm::dyn_cast<GroupprivateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GroupprivateOp GroupprivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::FlatSymbolRefAttr sym_name, /*optional*/::mlir::omp::DeclareTargetDeviceTypeAttr device_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(device_type)>(device_type));
|
|
}
|
|
|
|
void GroupprivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type gp_addr, ::llvm::StringRef sym_name, /*optional*/::mlir::omp::DeclareTargetDeviceTypeAttr device_type) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = ::mlir::SymbolRefAttr::get(odsBuilder.getContext(), sym_name);
|
|
if (device_type) {
|
|
odsState.getOrAddProperties<Properties>().device_type = device_type;
|
|
}
|
|
odsState.addTypes(gp_addr);
|
|
}
|
|
|
|
GroupprivateOp GroupprivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type gp_addr, ::llvm::StringRef sym_name, /*optional*/::mlir::omp::DeclareTargetDeviceTypeAttr device_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(gp_addr)>(gp_addr), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(device_type)>(device_type));
|
|
auto __res__ = ::llvm::dyn_cast<GroupprivateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GroupprivateOp GroupprivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type gp_addr, ::llvm::StringRef sym_name, /*optional*/::mlir::omp::DeclareTargetDeviceTypeAttr device_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(gp_addr)>(gp_addr), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(device_type)>(device_type));
|
|
}
|
|
|
|
void GroupprivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, /*optional*/::mlir::omp::DeclareTargetDeviceTypeAttr device_type) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = ::mlir::SymbolRefAttr::get(odsBuilder.getContext(), sym_name);
|
|
if (device_type) {
|
|
odsState.getOrAddProperties<Properties>().device_type = device_type;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
GroupprivateOp GroupprivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, /*optional*/::mlir::omp::DeclareTargetDeviceTypeAttr device_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(device_type)>(device_type));
|
|
auto __res__ = ::llvm::dyn_cast<GroupprivateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GroupprivateOp GroupprivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, /*optional*/::mlir::omp::DeclareTargetDeviceTypeAttr device_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(device_type)>(device_type));
|
|
}
|
|
|
|
void GroupprivateOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 0u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<GroupprivateOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
GroupprivateOp GroupprivateOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<GroupprivateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GroupprivateOp GroupprivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void GroupprivateOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
GroupprivateOp GroupprivateOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<GroupprivateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GroupprivateOp GroupprivateOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult GroupprivateOp::verifyInvariantsImpl() {
|
|
auto tblgen_device_type = getProperties().device_type; (void)tblgen_device_type;
|
|
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_OpenMPOps9(*this, tblgen_sym_name, "sym_name")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps15(*this, tblgen_device_type, "device_type")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSResults(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult GroupprivateOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult GroupprivateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::FlatSymbolRefAttr sym_nameAttr;
|
|
::mlir::omp::DeclareTargetDeviceTypeAttr device_typeAttr;
|
|
::mlir::Type gp_addrRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> gp_addrTypes(&gp_addrRawType, 1);
|
|
|
|
if (parser.parseCustomAttributeWithFallback(sym_nameAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
|
|
return ::mlir::failure();
|
|
}
|
|
if (sym_nameAttr) result.getOrAddProperties<GroupprivateOp::Properties>().sym_name = sym_nameAttr;
|
|
if (::mlir::succeeded(parser.parseOptionalKeyword("device_type"))) {
|
|
|
|
if (parser.parseCustomAttributeWithFallback(device_typeAttr, ::mlir::Type{})) {
|
|
return ::mlir::failure();
|
|
}
|
|
if (device_typeAttr) result.getOrAddProperties<GroupprivateOp::Properties>().device_type = device_typeAttr;
|
|
}
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
::mlir::omp::PointerLikeType type;
|
|
if (parser.parseCustomTypeWithFallback(type))
|
|
return ::mlir::failure();
|
|
gp_addrRawType = type;
|
|
}
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
|
|
return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
|
|
})))
|
|
return ::mlir::failure();
|
|
}
|
|
result.addTypes(gp_addrTypes);
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void GroupprivateOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printAttributeWithoutType(getSymNameAttr());
|
|
if (getDeviceTypeAttr()) {
|
|
_odsPrinter << ' ' << "device_type";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printStrippedAttrOrType(getDeviceTypeAttr());
|
|
}
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
{
|
|
auto type = getGpAddr().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::omp::PointerLikeType>(type))
|
|
_odsPrinter.printStrippedAttrOrType(validType);
|
|
else
|
|
_odsPrinter << type;
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("sym_name");
|
|
elidedAttrs.push_back("device_type");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
void GroupprivateOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::GroupprivateOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::GroupprivateOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::IteratorOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
IteratorOpGenericAdaptorBase::IteratorOpGenericAdaptorBase(IteratorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> IteratorOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::UnitAttr IteratorOpGenericAdaptorBase::getLoopInclusiveAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().loop_inclusive);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool IteratorOpGenericAdaptorBase::getLoopInclusive() {
|
|
auto attr = getLoopInclusiveAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
IteratorOpAdaptor::IteratorOpAdaptor(IteratorOp op) : IteratorOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult IteratorOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_loop_inclusive = getProperties().loop_inclusive; (void)tblgen_loop_inclusive;
|
|
|
|
if (tblgen_loop_inclusive && !((::llvm::isa<::mlir::UnitAttr>(tblgen_loop_inclusive))))
|
|
return emitError(loc, "'omp.iterator' op attribute 'loop_inclusive' failed to satisfy constraint: unit attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> IteratorOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange IteratorOp::getLoopLowerBoundsMutable() {
|
|
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 IteratorOp::getLoopUpperBoundsMutable() {
|
|
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 IteratorOp::getLoopStepsMutable() {
|
|
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 IteratorOp::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.loop_inclusive;
|
|
auto attr = dict.get("loop_inclusive");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `loop_inclusive` 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 IteratorOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.loop_inclusive;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("loop_inclusive",
|
|
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 IteratorOp::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.loop_inclusive.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> IteratorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "loop_inclusive")
|
|
return prop.loop_inclusive;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void IteratorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "loop_inclusive") {
|
|
prop.loop_inclusive = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.loop_inclusive)>>(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 IteratorOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.loop_inclusive) attrs.append("loop_inclusive", prop.loop_inclusive);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult IteratorOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getLoopInclusiveAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "loop_inclusive", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult IteratorOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.loop_inclusive)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(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 IteratorOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.loop_inclusive);
|
|
|
|
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 IteratorOp::getLoopInclusive() {
|
|
auto attr = getLoopInclusiveAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
void IteratorOp::setLoopInclusive(bool attrValue) {
|
|
auto &odsProp = getProperties().loop_inclusive;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void IteratorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type iterated, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/::mlir::UnitAttr loop_inclusive) {
|
|
odsState.addOperands(loop_lower_bounds);
|
|
odsState.addOperands(loop_upper_bounds);
|
|
odsState.addOperands(loop_steps);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(loop_lower_bounds.size()), static_cast<int32_t>(loop_upper_bounds.size()), static_cast<int32_t>(loop_steps.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (loop_inclusive) {
|
|
odsState.getOrAddProperties<Properties>().loop_inclusive = loop_inclusive;
|
|
}
|
|
(void)odsState.addRegion();
|
|
odsState.addTypes(iterated);
|
|
}
|
|
|
|
IteratorOp IteratorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type iterated, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/::mlir::UnitAttr loop_inclusive) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(iterated)>(iterated), std::forward<decltype(loop_lower_bounds)>(loop_lower_bounds), std::forward<decltype(loop_upper_bounds)>(loop_upper_bounds), std::forward<decltype(loop_steps)>(loop_steps), std::forward<decltype(loop_inclusive)>(loop_inclusive));
|
|
auto __res__ = ::llvm::dyn_cast<IteratorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IteratorOp IteratorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type iterated, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/::mlir::UnitAttr loop_inclusive) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(iterated)>(iterated), std::forward<decltype(loop_lower_bounds)>(loop_lower_bounds), std::forward<decltype(loop_upper_bounds)>(loop_upper_bounds), std::forward<decltype(loop_steps)>(loop_steps), std::forward<decltype(loop_inclusive)>(loop_inclusive));
|
|
}
|
|
|
|
void IteratorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/::mlir::UnitAttr loop_inclusive) {
|
|
odsState.addOperands(loop_lower_bounds);
|
|
odsState.addOperands(loop_upper_bounds);
|
|
odsState.addOperands(loop_steps);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(loop_lower_bounds.size()), static_cast<int32_t>(loop_upper_bounds.size()), static_cast<int32_t>(loop_steps.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (loop_inclusive) {
|
|
odsState.getOrAddProperties<Properties>().loop_inclusive = loop_inclusive;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
IteratorOp IteratorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/::mlir::UnitAttr loop_inclusive) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(loop_lower_bounds)>(loop_lower_bounds), std::forward<decltype(loop_upper_bounds)>(loop_upper_bounds), std::forward<decltype(loop_steps)>(loop_steps), std::forward<decltype(loop_inclusive)>(loop_inclusive));
|
|
auto __res__ = ::llvm::dyn_cast<IteratorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IteratorOp IteratorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/::mlir::UnitAttr loop_inclusive) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(loop_lower_bounds)>(loop_lower_bounds), std::forward<decltype(loop_upper_bounds)>(loop_upper_bounds), std::forward<decltype(loop_steps)>(loop_steps), std::forward<decltype(loop_inclusive)>(loop_inclusive));
|
|
}
|
|
|
|
void IteratorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type iterated, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/bool loop_inclusive) {
|
|
odsState.addOperands(loop_lower_bounds);
|
|
odsState.addOperands(loop_upper_bounds);
|
|
odsState.addOperands(loop_steps);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(loop_lower_bounds.size()), static_cast<int32_t>(loop_upper_bounds.size()), static_cast<int32_t>(loop_steps.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (loop_inclusive) {
|
|
odsState.getOrAddProperties<Properties>().loop_inclusive = ((loop_inclusive) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
(void)odsState.addRegion();
|
|
odsState.addTypes(iterated);
|
|
}
|
|
|
|
IteratorOp IteratorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type iterated, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/bool loop_inclusive) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(iterated)>(iterated), std::forward<decltype(loop_lower_bounds)>(loop_lower_bounds), std::forward<decltype(loop_upper_bounds)>(loop_upper_bounds), std::forward<decltype(loop_steps)>(loop_steps), std::forward<decltype(loop_inclusive)>(loop_inclusive));
|
|
auto __res__ = ::llvm::dyn_cast<IteratorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IteratorOp IteratorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type iterated, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/bool loop_inclusive) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(iterated)>(iterated), std::forward<decltype(loop_lower_bounds)>(loop_lower_bounds), std::forward<decltype(loop_upper_bounds)>(loop_upper_bounds), std::forward<decltype(loop_steps)>(loop_steps), std::forward<decltype(loop_inclusive)>(loop_inclusive));
|
|
}
|
|
|
|
void IteratorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/bool loop_inclusive) {
|
|
odsState.addOperands(loop_lower_bounds);
|
|
odsState.addOperands(loop_upper_bounds);
|
|
odsState.addOperands(loop_steps);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(loop_lower_bounds.size()), static_cast<int32_t>(loop_upper_bounds.size()), static_cast<int32_t>(loop_steps.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (loop_inclusive) {
|
|
odsState.getOrAddProperties<Properties>().loop_inclusive = ((loop_inclusive) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
IteratorOp IteratorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/bool loop_inclusive) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(loop_lower_bounds)>(loop_lower_bounds), std::forward<decltype(loop_upper_bounds)>(loop_upper_bounds), std::forward<decltype(loop_steps)>(loop_steps), std::forward<decltype(loop_inclusive)>(loop_inclusive));
|
|
auto __res__ = ::llvm::dyn_cast<IteratorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IteratorOp IteratorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/bool loop_inclusive) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(loop_lower_bounds)>(loop_lower_bounds), std::forward<decltype(loop_upper_bounds)>(loop_upper_bounds), std::forward<decltype(loop_steps)>(loop_steps), std::forward<decltype(loop_inclusive)>(loop_inclusive));
|
|
}
|
|
|
|
void IteratorOp::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() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<IteratorOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
IteratorOp IteratorOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<IteratorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IteratorOp IteratorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void IteratorOp::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&>(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);
|
|
}
|
|
|
|
IteratorOp IteratorOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<IteratorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IteratorOp IteratorOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult IteratorOp::verifyInvariantsImpl() {
|
|
auto tblgen_loop_inclusive = getProperties().loop_inclusive; (void)tblgen_loop_inclusive;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_loop_inclusive, "loop_inclusive")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps14(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps14(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps14(*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_OpenMPOps15(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
if (!(((this->getODSOperands(0).getType()) == (this->getODSOperands(1).getType()) && (this->getODSOperands(1).getType()) == (this->getODSOperands(2).getType()) && (this->getODSOperands(2).getType()) == (this->getODSOperands(0).getType()))))
|
|
return emitOpError("failed to verify that all of {loop_lower_bounds, loop_upper_bounds, loop_steps} have same type");
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps1(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult IteratorOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult IteratorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> loop_lower_boundsOperands;
|
|
::llvm::SMLoc loop_lower_boundsOperandsLoc;
|
|
(void)loop_lower_boundsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> loop_upper_boundsOperands;
|
|
::llvm::SMLoc loop_upper_boundsOperandsLoc;
|
|
(void)loop_upper_boundsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> loop_stepsOperands;
|
|
::llvm::SMLoc loop_stepsOperandsLoc;
|
|
(void)loop_stepsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> loop_lower_boundsTypes;
|
|
::llvm::SmallVector<::mlir::Type, 1> loop_upper_boundsTypes;
|
|
::llvm::SmallVector<::mlir::Type, 1> loop_stepsTypes;
|
|
::mlir::Type iteratedRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> iteratedTypes(&iteratedRawType, 1);
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
loop_lower_boundsOperandsLoc = parser.getCurrentLocation();
|
|
loop_upper_boundsOperandsLoc = parser.getCurrentLocation();
|
|
loop_stepsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseIteratorHeader(parser, *regionRegion, loop_lower_boundsOperands, loop_upper_boundsOperands, loop_stepsOperands, loop_lower_boundsTypes, loop_upper_boundsTypes, loop_stepsTypes);
|
|
if (odsResult) return ::mlir::failure();
|
|
}
|
|
if (parser.parseArrow())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseType(iteratedRawType))
|
|
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));
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(loop_lower_boundsOperands.size()), static_cast<int32_t>(loop_upper_boundsOperands.size()), static_cast<int32_t>(loop_stepsOperands.size())}), result.getOrAddProperties<IteratorOp::Properties>().operandSegmentSizes.begin());
|
|
result.addTypes(iteratedTypes);
|
|
if (parser.resolveOperands(loop_lower_boundsOperands, loop_lower_boundsTypes, loop_lower_boundsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(loop_upper_boundsOperands, loop_upper_boundsTypes, loop_upper_boundsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(loop_stepsOperands, loop_stepsTypes, loop_stepsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void IteratorOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << "(";
|
|
printIteratorHeader(_odsPrinter, *this, getRegion(), getLoopLowerBounds(), getLoopUpperBounds(), getLoopSteps(), getLoopLowerBounds().getTypes(), getLoopUpperBounds().getTypes(), getLoopSteps().getTypes());
|
|
_odsPrinter << ' ' << "->";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getIterated().getType();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getLoopInclusiveAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("loop_inclusive");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::IteratorOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::IteratorOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::LoopNestOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
LoopNestOpGenericAdaptorBase::LoopNestOpGenericAdaptorBase(LoopNestOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> LoopNestOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
bool isVariadic[] = {true, true, true};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (odsOperandsSize - 0) / 3;
|
|
// `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::IntegerAttr LoopNestOpGenericAdaptorBase::getCollapseNumLoopsAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().collapse_num_loops);
|
|
if (!attr)
|
|
attr = ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(64), 1);
|
|
return attr;
|
|
}
|
|
|
|
uint64_t LoopNestOpGenericAdaptorBase::getCollapseNumLoops() {
|
|
auto attr = getCollapseNumLoopsAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(64), 1).getValue().getZExtValue();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
::mlir::UnitAttr LoopNestOpGenericAdaptorBase::getLoopInclusiveAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().loop_inclusive);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool LoopNestOpGenericAdaptorBase::getLoopInclusive() {
|
|
auto attr = getLoopInclusiveAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<int64_t>> LoopNestOpGenericAdaptorBase::getTileSizes() {
|
|
auto attr = getTileSizesAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<int64_t>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
LoopNestOpAdaptor::LoopNestOpAdaptor(LoopNestOp op) : LoopNestOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult LoopNestOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_collapse_num_loops = getProperties().collapse_num_loops; (void)tblgen_collapse_num_loops;
|
|
auto tblgen_loop_inclusive = getProperties().loop_inclusive; (void)tblgen_loop_inclusive;
|
|
auto tblgen_tile_sizes = getProperties().tile_sizes; (void)tblgen_tile_sizes;
|
|
|
|
if (tblgen_collapse_num_loops && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_collapse_num_loops))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_collapse_num_loops).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_collapse_num_loops).getInt() >= 1))))
|
|
return emitError(loc, "'omp.loop_nest' op attribute 'collapse_num_loops' failed to satisfy constraint: 64-bit signless integer attribute whose minimum value is 1");
|
|
|
|
if (tblgen_loop_inclusive && !((::llvm::isa<::mlir::UnitAttr>(tblgen_loop_inclusive))))
|
|
return emitError(loc, "'omp.loop_nest' op attribute 'loop_inclusive' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_tile_sizes && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_tile_sizes))))
|
|
return emitError(loc, "'omp.loop_nest' op attribute 'tile_sizes' failed to satisfy constraint: i64 dense array attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> LoopNestOp::getODSOperandIndexAndLength(unsigned index) {
|
|
bool isVariadic[] = {true, true, true};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (getOperation()->getNumOperands() - 0) / 3;
|
|
// `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 LoopNestOp::getLoopLowerBoundsMutable() {
|
|
auto range = getODSOperandIndexAndLength(0);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
|
|
return mutableRange;
|
|
}
|
|
|
|
::mlir::MutableOperandRange LoopNestOp::getLoopUpperBoundsMutable() {
|
|
auto range = getODSOperandIndexAndLength(1);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
|
|
return mutableRange;
|
|
}
|
|
|
|
::mlir::MutableOperandRange LoopNestOp::getLoopStepsMutable() {
|
|
auto range = getODSOperandIndexAndLength(2);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
|
|
return mutableRange;
|
|
}
|
|
|
|
::llvm::LogicalResult LoopNestOp::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.collapse_num_loops;
|
|
auto attr = dict.get("collapse_num_loops");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `collapse_num_loops` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.loop_inclusive;
|
|
auto attr = dict.get("loop_inclusive");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `loop_inclusive` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.tile_sizes;
|
|
auto attr = dict.get("tile_sizes");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `tile_sizes` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute LoopNestOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.collapse_num_loops;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("collapse_num_loops",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.loop_inclusive;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("loop_inclusive",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.tile_sizes;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("tile_sizes",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code LoopNestOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.collapse_num_loops.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.loop_inclusive.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.tile_sizes.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> LoopNestOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "collapse_num_loops")
|
|
return prop.collapse_num_loops;
|
|
|
|
if (name == "loop_inclusive")
|
|
return prop.loop_inclusive;
|
|
|
|
if (name == "tile_sizes")
|
|
return prop.tile_sizes;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void LoopNestOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "collapse_num_loops") {
|
|
prop.collapse_num_loops = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.collapse_num_loops)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "loop_inclusive") {
|
|
prop.loop_inclusive = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.loop_inclusive)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "tile_sizes") {
|
|
prop.tile_sizes = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.tile_sizes)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void LoopNestOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.collapse_num_loops) attrs.append("collapse_num_loops", prop.collapse_num_loops);
|
|
|
|
if (prop.loop_inclusive) attrs.append("loop_inclusive", prop.loop_inclusive);
|
|
|
|
if (prop.tile_sizes) attrs.append("tile_sizes", prop.tile_sizes);
|
|
}
|
|
|
|
::llvm::LogicalResult LoopNestOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getCollapseNumLoopsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps16(attr, "collapse_num_loops", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getLoopInclusiveAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "loop_inclusive", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getTileSizesAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps17(attr, "tile_sizes", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LoopNestOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.collapse_num_loops)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.loop_inclusive)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.tile_sizes)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void LoopNestOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.collapse_num_loops);
|
|
|
|
writer.writeOptionalAttribute(prop.loop_inclusive);
|
|
|
|
writer.writeOptionalAttribute(prop.tile_sizes);
|
|
}
|
|
|
|
uint64_t LoopNestOp::getCollapseNumLoops() {
|
|
auto attr = getCollapseNumLoopsAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), 1).getValue().getZExtValue();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
bool LoopNestOp::getLoopInclusive() {
|
|
auto attr = getLoopInclusiveAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<int64_t>> LoopNestOp::getTileSizes() {
|
|
auto attr = getTileSizesAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<int64_t>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
void LoopNestOp::setCollapseNumLoops(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().collapse_num_loops;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void LoopNestOp::setLoopInclusive(bool attrValue) {
|
|
auto &odsProp = getProperties().loop_inclusive;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void LoopNestOp::setTileSizes(::std::optional<::llvm::ArrayRef<int64_t>> attrValue) {
|
|
auto &odsProp = getProperties().tile_sizes;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
LoopNestOp LoopNestOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const LoopNestOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<LoopNestOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LoopNestOp LoopNestOp::create(::mlir::ImplicitLocOpBuilder &builder, const LoopNestOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void LoopNestOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::IntegerAttr collapse_num_loops, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/::mlir::UnitAttr loop_inclusive, /*optional*/::mlir::DenseI64ArrayAttr tile_sizes) {
|
|
odsState.addOperands(loop_lower_bounds);
|
|
odsState.addOperands(loop_upper_bounds);
|
|
odsState.addOperands(loop_steps);
|
|
if (collapse_num_loops) {
|
|
odsState.getOrAddProperties<Properties>().collapse_num_loops = collapse_num_loops;
|
|
}
|
|
if (loop_inclusive) {
|
|
odsState.getOrAddProperties<Properties>().loop_inclusive = loop_inclusive;
|
|
}
|
|
if (tile_sizes) {
|
|
odsState.getOrAddProperties<Properties>().tile_sizes = tile_sizes;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
LoopNestOp LoopNestOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::IntegerAttr collapse_num_loops, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/::mlir::UnitAttr loop_inclusive, /*optional*/::mlir::DenseI64ArrayAttr tile_sizes) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(collapse_num_loops)>(collapse_num_loops), std::forward<decltype(loop_lower_bounds)>(loop_lower_bounds), std::forward<decltype(loop_upper_bounds)>(loop_upper_bounds), std::forward<decltype(loop_steps)>(loop_steps), std::forward<decltype(loop_inclusive)>(loop_inclusive), std::forward<decltype(tile_sizes)>(tile_sizes));
|
|
auto __res__ = ::llvm::dyn_cast<LoopNestOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LoopNestOp LoopNestOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::IntegerAttr collapse_num_loops, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/::mlir::UnitAttr loop_inclusive, /*optional*/::mlir::DenseI64ArrayAttr tile_sizes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(collapse_num_loops)>(collapse_num_loops), std::forward<decltype(loop_lower_bounds)>(loop_lower_bounds), std::forward<decltype(loop_upper_bounds)>(loop_upper_bounds), std::forward<decltype(loop_steps)>(loop_steps), std::forward<decltype(loop_inclusive)>(loop_inclusive), std::forward<decltype(tile_sizes)>(tile_sizes));
|
|
}
|
|
|
|
void LoopNestOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::IntegerAttr collapse_num_loops, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/::mlir::UnitAttr loop_inclusive, /*optional*/::mlir::DenseI64ArrayAttr tile_sizes) {
|
|
odsState.addOperands(loop_lower_bounds);
|
|
odsState.addOperands(loop_upper_bounds);
|
|
odsState.addOperands(loop_steps);
|
|
if (collapse_num_loops) {
|
|
odsState.getOrAddProperties<Properties>().collapse_num_loops = collapse_num_loops;
|
|
}
|
|
if (loop_inclusive) {
|
|
odsState.getOrAddProperties<Properties>().loop_inclusive = loop_inclusive;
|
|
}
|
|
if (tile_sizes) {
|
|
odsState.getOrAddProperties<Properties>().tile_sizes = tile_sizes;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LoopNestOp LoopNestOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::IntegerAttr collapse_num_loops, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/::mlir::UnitAttr loop_inclusive, /*optional*/::mlir::DenseI64ArrayAttr tile_sizes) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(collapse_num_loops)>(collapse_num_loops), std::forward<decltype(loop_lower_bounds)>(loop_lower_bounds), std::forward<decltype(loop_upper_bounds)>(loop_upper_bounds), std::forward<decltype(loop_steps)>(loop_steps), std::forward<decltype(loop_inclusive)>(loop_inclusive), std::forward<decltype(tile_sizes)>(tile_sizes));
|
|
auto __res__ = ::llvm::dyn_cast<LoopNestOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LoopNestOp LoopNestOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::IntegerAttr collapse_num_loops, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/::mlir::UnitAttr loop_inclusive, /*optional*/::mlir::DenseI64ArrayAttr tile_sizes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(collapse_num_loops)>(collapse_num_loops), std::forward<decltype(loop_lower_bounds)>(loop_lower_bounds), std::forward<decltype(loop_upper_bounds)>(loop_upper_bounds), std::forward<decltype(loop_steps)>(loop_steps), std::forward<decltype(loop_inclusive)>(loop_inclusive), std::forward<decltype(tile_sizes)>(tile_sizes));
|
|
}
|
|
|
|
void LoopNestOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/uint64_t collapse_num_loops, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/bool loop_inclusive, /*optional*/::mlir::DenseI64ArrayAttr tile_sizes) {
|
|
odsState.addOperands(loop_lower_bounds);
|
|
odsState.addOperands(loop_upper_bounds);
|
|
odsState.addOperands(loop_steps);
|
|
odsState.getOrAddProperties<Properties>().collapse_num_loops = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), collapse_num_loops);
|
|
if (loop_inclusive) {
|
|
odsState.getOrAddProperties<Properties>().loop_inclusive = ((loop_inclusive) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (tile_sizes) {
|
|
odsState.getOrAddProperties<Properties>().tile_sizes = tile_sizes;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
LoopNestOp LoopNestOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/uint64_t collapse_num_loops, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/bool loop_inclusive, /*optional*/::mlir::DenseI64ArrayAttr tile_sizes) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(collapse_num_loops)>(collapse_num_loops), std::forward<decltype(loop_lower_bounds)>(loop_lower_bounds), std::forward<decltype(loop_upper_bounds)>(loop_upper_bounds), std::forward<decltype(loop_steps)>(loop_steps), std::forward<decltype(loop_inclusive)>(loop_inclusive), std::forward<decltype(tile_sizes)>(tile_sizes));
|
|
auto __res__ = ::llvm::dyn_cast<LoopNestOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LoopNestOp LoopNestOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/uint64_t collapse_num_loops, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/bool loop_inclusive, /*optional*/::mlir::DenseI64ArrayAttr tile_sizes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(collapse_num_loops)>(collapse_num_loops), std::forward<decltype(loop_lower_bounds)>(loop_lower_bounds), std::forward<decltype(loop_upper_bounds)>(loop_upper_bounds), std::forward<decltype(loop_steps)>(loop_steps), std::forward<decltype(loop_inclusive)>(loop_inclusive), std::forward<decltype(tile_sizes)>(tile_sizes));
|
|
}
|
|
|
|
void LoopNestOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/uint64_t collapse_num_loops, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/bool loop_inclusive, /*optional*/::mlir::DenseI64ArrayAttr tile_sizes) {
|
|
odsState.addOperands(loop_lower_bounds);
|
|
odsState.addOperands(loop_upper_bounds);
|
|
odsState.addOperands(loop_steps);
|
|
odsState.getOrAddProperties<Properties>().collapse_num_loops = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), collapse_num_loops);
|
|
if (loop_inclusive) {
|
|
odsState.getOrAddProperties<Properties>().loop_inclusive = ((loop_inclusive) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (tile_sizes) {
|
|
odsState.getOrAddProperties<Properties>().tile_sizes = tile_sizes;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LoopNestOp LoopNestOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/uint64_t collapse_num_loops, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/bool loop_inclusive, /*optional*/::mlir::DenseI64ArrayAttr tile_sizes) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(collapse_num_loops)>(collapse_num_loops), std::forward<decltype(loop_lower_bounds)>(loop_lower_bounds), std::forward<decltype(loop_upper_bounds)>(loop_upper_bounds), std::forward<decltype(loop_steps)>(loop_steps), std::forward<decltype(loop_inclusive)>(loop_inclusive), std::forward<decltype(tile_sizes)>(tile_sizes));
|
|
auto __res__ = ::llvm::dyn_cast<LoopNestOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LoopNestOp LoopNestOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/uint64_t collapse_num_loops, ::mlir::ValueRange loop_lower_bounds, ::mlir::ValueRange loop_upper_bounds, ::mlir::ValueRange loop_steps, /*optional*/bool loop_inclusive, /*optional*/::mlir::DenseI64ArrayAttr tile_sizes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(collapse_num_loops)>(collapse_num_loops), std::forward<decltype(loop_lower_bounds)>(loop_lower_bounds), std::forward<decltype(loop_upper_bounds)>(loop_upper_bounds), std::forward<decltype(loop_steps)>(loop_steps), std::forward<decltype(loop_inclusive)>(loop_inclusive), std::forward<decltype(tile_sizes)>(tile_sizes));
|
|
}
|
|
|
|
void LoopNestOp::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<LoopNestOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
LoopNestOp LoopNestOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<LoopNestOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LoopNestOp LoopNestOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void LoopNestOp::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&>(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);
|
|
}
|
|
|
|
LoopNestOp LoopNestOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<LoopNestOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LoopNestOp LoopNestOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult LoopNestOp::verifyInvariantsImpl() {
|
|
auto tblgen_collapse_num_loops = getProperties().collapse_num_loops; (void)tblgen_collapse_num_loops;
|
|
auto tblgen_loop_inclusive = getProperties().loop_inclusive; (void)tblgen_loop_inclusive;
|
|
auto tblgen_tile_sizes = getProperties().tile_sizes; (void)tblgen_tile_sizes;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps16(*this, tblgen_collapse_num_loops, "collapse_num_loops")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_loop_inclusive, "loop_inclusive")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps17(*this, tblgen_tile_sizes, "tile_sizes")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps14(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps14(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps14(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
if (!(((this->getODSOperands(0).getType()) == (this->getODSOperands(1).getType()) && (this->getODSOperands(1).getType()) == (this->getODSOperands(2).getType()) && (this->getODSOperands(2).getType()) == (this->getODSOperands(0).getType()))))
|
|
return emitOpError("failed to verify that all of {loop_lower_bounds, loop_upper_bounds, loop_steps} have same type");
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LoopNestOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult LoopNestOp::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.collapse_num_loops;
|
|
auto collapse_num_loopsAttrName = ::mlir::StringAttr::get(ctx, "collapse_num_loops");
|
|
auto attr = dict.get(collapse_num_loopsAttrName);
|
|
usedKeys.insert(collapse_num_loopsAttrName);
|
|
if (attr || /*isRequired=*/false) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for collapse_num_loops in DictionaryAttr to set "
|
|
"Properties.";
|
|
return ::mlir::failure();
|
|
}
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `collapse_num_loops` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
{
|
|
|
|
auto &propStorage = prop.loop_inclusive;
|
|
auto loop_inclusiveAttrName = ::mlir::StringAttr::get(ctx, "loop_inclusive");
|
|
auto attr = dict.get(loop_inclusiveAttrName);
|
|
usedKeys.insert(loop_inclusiveAttrName);
|
|
if (attr || /*isRequired=*/false) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for loop_inclusive in DictionaryAttr to set "
|
|
"Properties.";
|
|
return ::mlir::failure();
|
|
}
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `loop_inclusive` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
{
|
|
|
|
auto &propStorage = prop.tile_sizes;
|
|
auto tile_sizesAttrName = ::mlir::StringAttr::get(ctx, "tile_sizes");
|
|
auto attr = dict.get(tile_sizesAttrName);
|
|
usedKeys.insert(tile_sizesAttrName);
|
|
if (attr || /*isRequired=*/false) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for tile_sizes in DictionaryAttr to set "
|
|
"Properties.";
|
|
return ::mlir::failure();
|
|
}
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `tile_sizes` 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::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::LoopNestOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::LoopNestOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::LoopOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
LoopOpGenericAdaptorBase::LoopOpGenericAdaptorBase(LoopOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> LoopOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseBindKind> LoopOpGenericAdaptorBase::getBindKind() {
|
|
auto attr = getBindKindAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseBindKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > LoopOpGenericAdaptorBase::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr LoopOpGenericAdaptorBase::getPrivateNeedsBarrierAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().private_needs_barrier);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool LoopOpGenericAdaptorBase::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseOrderKind> LoopOpGenericAdaptorBase::getOrder() {
|
|
auto attr = getOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::OrderModifier> LoopOpGenericAdaptorBase::getOrderMod() {
|
|
auto attr = getOrderModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::OrderModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ReductionModifier> LoopOpGenericAdaptorBase::getReductionMod() {
|
|
auto attr = getReductionModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ReductionModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> LoopOpGenericAdaptorBase::getReductionByref() {
|
|
auto attr = getReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > LoopOpGenericAdaptorBase::getReductionSyms() {
|
|
auto attr = getReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
LoopOpAdaptor::LoopOpAdaptor(LoopOp op) : LoopOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult LoopOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_bind_kind = getProperties().bind_kind; (void)tblgen_bind_kind;
|
|
auto tblgen_order = getProperties().order; (void)tblgen_order;
|
|
auto tblgen_order_mod = getProperties().order_mod; (void)tblgen_order_mod;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_reduction_byref = getProperties().reduction_byref; (void)tblgen_reduction_byref;
|
|
auto tblgen_reduction_mod = getProperties().reduction_mod; (void)tblgen_reduction_mod;
|
|
auto tblgen_reduction_syms = getProperties().reduction_syms; (void)tblgen_reduction_syms;
|
|
|
|
if (tblgen_bind_kind && !((::llvm::isa<::mlir::omp::ClauseBindKindAttr>(tblgen_bind_kind))))
|
|
return emitError(loc, "'omp.loop' op attribute 'bind_kind' failed to satisfy constraint: BindKind Clause");
|
|
|
|
if (tblgen_private_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_private_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_private_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.loop' op attribute 'private_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_private_needs_barrier && !((::llvm::isa<::mlir::UnitAttr>(tblgen_private_needs_barrier))))
|
|
return emitError(loc, "'omp.loop' op attribute 'private_needs_barrier' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_order && !((::llvm::isa<::mlir::omp::ClauseOrderKindAttr>(tblgen_order))))
|
|
return emitError(loc, "'omp.loop' op attribute 'order' failed to satisfy constraint: OrderKind Clause");
|
|
|
|
if (tblgen_order_mod && !((::llvm::isa<::mlir::omp::OrderModifierAttr>(tblgen_order_mod))))
|
|
return emitError(loc, "'omp.loop' op attribute 'order_mod' failed to satisfy constraint: OpenMP Order Modifier");
|
|
|
|
if (tblgen_reduction_mod && !((::llvm::isa<::mlir::omp::ReductionModifierAttr>(tblgen_reduction_mod))))
|
|
return emitError(loc, "'omp.loop' op attribute 'reduction_mod' failed to satisfy constraint: reduction modifier");
|
|
|
|
if (tblgen_reduction_byref && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(tblgen_reduction_byref))))
|
|
return emitError(loc, "'omp.loop' op attribute 'reduction_byref' failed to satisfy constraint: i1 dense array attribute");
|
|
|
|
if (tblgen_reduction_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_reduction_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_reduction_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.loop' op attribute 'reduction_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> LoopOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange LoopOp::getPrivateVarsMutable() {
|
|
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::getReductionVarsMutable() {
|
|
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 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.bind_kind;
|
|
auto attr = dict.get("bind_kind");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `bind_kind` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.order;
|
|
auto attr = dict.get("order");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `order` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.order_mod;
|
|
auto attr = dict.get("order_mod");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `order_mod` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_needs_barrier;
|
|
auto attr = dict.get("private_needs_barrier");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_needs_barrier` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_syms;
|
|
auto attr = dict.get("private_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_syms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_byref;
|
|
auto attr = dict.get("reduction_byref");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_byref` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_mod;
|
|
auto attr = dict.get("reduction_mod");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_mod` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_syms;
|
|
auto attr = dict.get("reduction_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_syms` 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.bind_kind;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("bind_kind",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.order;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("order",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.order_mod;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("order_mod",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_needs_barrier;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_needs_barrier",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_syms",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_byref;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_byref",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_mod;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_mod",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_syms",
|
|
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.bind_kind.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.order.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.order_mod.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_needs_barrier.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_syms.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_byref.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_mod.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_syms.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> LoopOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "bind_kind")
|
|
return prop.bind_kind;
|
|
|
|
if (name == "order")
|
|
return prop.order;
|
|
|
|
if (name == "order_mod")
|
|
return prop.order_mod;
|
|
|
|
if (name == "private_needs_barrier")
|
|
return prop.private_needs_barrier;
|
|
|
|
if (name == "private_syms")
|
|
return prop.private_syms;
|
|
|
|
if (name == "reduction_byref")
|
|
return prop.reduction_byref;
|
|
|
|
if (name == "reduction_mod")
|
|
return prop.reduction_mod;
|
|
|
|
if (name == "reduction_syms")
|
|
return prop.reduction_syms;
|
|
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 == "bind_kind") {
|
|
prop.bind_kind = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.bind_kind)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "order") {
|
|
prop.order = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.order)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "order_mod") {
|
|
prop.order_mod = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.order_mod)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_needs_barrier") {
|
|
prop.private_needs_barrier = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_needs_barrier)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_syms") {
|
|
prop.private_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_syms)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_byref") {
|
|
prop.reduction_byref = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_byref)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_mod") {
|
|
prop.reduction_mod = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_mod)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_syms") {
|
|
prop.reduction_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_syms)>>(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.bind_kind) attrs.append("bind_kind", prop.bind_kind);
|
|
|
|
if (prop.order) attrs.append("order", prop.order);
|
|
|
|
if (prop.order_mod) attrs.append("order_mod", prop.order_mod);
|
|
|
|
if (prop.private_needs_barrier) attrs.append("private_needs_barrier", prop.private_needs_barrier);
|
|
|
|
if (prop.private_syms) attrs.append("private_syms", prop.private_syms);
|
|
|
|
if (prop.reduction_byref) attrs.append("reduction_byref", prop.reduction_byref);
|
|
|
|
if (prop.reduction_mod) attrs.append("reduction_mod", prop.reduction_mod);
|
|
|
|
if (prop.reduction_syms) attrs.append("reduction_syms", prop.reduction_syms);
|
|
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(getBindKindAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps18(attr, "bind_kind", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getOrderAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps12(attr, "order", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getOrderModAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps13(attr, "order_mod", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateNeedsBarrierAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "private_needs_barrier", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "private_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionByrefAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(attr, "reduction_byref", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionModAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps19(attr, "reduction_mod", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "reduction_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LoopOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.bind_kind)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.order)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.order_mod)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_needs_barrier)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_syms)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_byref)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_mod)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_syms)))
|
|
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.bind_kind);
|
|
|
|
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
|
|
}
|
|
|
|
writer.writeOptionalAttribute(prop.order);
|
|
|
|
writer.writeOptionalAttribute(prop.order_mod);
|
|
|
|
writer.writeOptionalAttribute(prop.private_needs_barrier);
|
|
|
|
writer.writeOptionalAttribute(prop.private_syms);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_byref);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_mod);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_syms);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseBindKind> LoopOp::getBindKind() {
|
|
auto attr = getBindKindAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseBindKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > LoopOp::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool LoopOp::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseOrderKind> LoopOp::getOrder() {
|
|
auto attr = getOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::OrderModifier> LoopOp::getOrderMod() {
|
|
auto attr = getOrderModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::OrderModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ReductionModifier> LoopOp::getReductionMod() {
|
|
auto attr = getReductionModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ReductionModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> LoopOp::getReductionByref() {
|
|
auto attr = getReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > LoopOp::getReductionSyms() {
|
|
auto attr = getReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
void LoopOp::setBindKind(::std::optional<::mlir::omp::ClauseBindKind> attrValue) {
|
|
auto &odsProp = getProperties().bind_kind;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ClauseBindKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void LoopOp::setPrivateNeedsBarrier(bool attrValue) {
|
|
auto &odsProp = getProperties().private_needs_barrier;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void LoopOp::setOrder(::std::optional<::mlir::omp::ClauseOrderKind> attrValue) {
|
|
auto &odsProp = getProperties().order;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ClauseOrderKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void LoopOp::setOrderMod(::std::optional<::mlir::omp::OrderModifier> attrValue) {
|
|
auto &odsProp = getProperties().order_mod;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::OrderModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void LoopOp::setReductionMod(::std::optional<::mlir::omp::ReductionModifier> attrValue) {
|
|
auto &odsProp = getProperties().reduction_mod;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ReductionModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void LoopOp::setReductionByref(::std::optional<::llvm::ArrayRef<bool>> attrValue) {
|
|
auto &odsProp = getProperties().reduction_byref;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getDenseBoolArrayAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
LoopOp LoopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const LoopOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<LoopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LoopOp LoopOp::create(::mlir::ImplicitLocOpBuilder &builder, const LoopOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void LoopOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::omp::ClauseBindKindAttr bind_kind, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (bind_kind) {
|
|
odsState.getOrAddProperties<Properties>().bind_kind = bind_kind;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (order) {
|
|
odsState.getOrAddProperties<Properties>().order = order;
|
|
}
|
|
if (order_mod) {
|
|
odsState.getOrAddProperties<Properties>().order_mod = order_mod;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
LoopOp LoopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::omp::ClauseBindKindAttr bind_kind, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(bind_kind)>(bind_kind), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<LoopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LoopOp LoopOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::omp::ClauseBindKindAttr bind_kind, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(bind_kind)>(bind_kind), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
}
|
|
|
|
void LoopOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::omp::ClauseBindKindAttr bind_kind, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (bind_kind) {
|
|
odsState.getOrAddProperties<Properties>().bind_kind = bind_kind;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (order) {
|
|
odsState.getOrAddProperties<Properties>().order = order;
|
|
}
|
|
if (order_mod) {
|
|
odsState.getOrAddProperties<Properties>().order_mod = order_mod;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LoopOp LoopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::omp::ClauseBindKindAttr bind_kind, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(bind_kind)>(bind_kind), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<LoopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LoopOp LoopOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::omp::ClauseBindKindAttr bind_kind, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(bind_kind)>(bind_kind), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
}
|
|
|
|
void LoopOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::omp::ClauseBindKindAttr bind_kind, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (bind_kind) {
|
|
odsState.getOrAddProperties<Properties>().bind_kind = bind_kind;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (order) {
|
|
odsState.getOrAddProperties<Properties>().order = order;
|
|
}
|
|
if (order_mod) {
|
|
odsState.getOrAddProperties<Properties>().order_mod = order_mod;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
LoopOp LoopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::omp::ClauseBindKindAttr bind_kind, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(bind_kind)>(bind_kind), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<LoopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LoopOp LoopOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::omp::ClauseBindKindAttr bind_kind, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(bind_kind)>(bind_kind), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
}
|
|
|
|
void LoopOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::omp::ClauseBindKindAttr bind_kind, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (bind_kind) {
|
|
odsState.getOrAddProperties<Properties>().bind_kind = bind_kind;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (order) {
|
|
odsState.getOrAddProperties<Properties>().order = order;
|
|
}
|
|
if (order_mod) {
|
|
odsState.getOrAddProperties<Properties>().order_mod = order_mod;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LoopOp LoopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::omp::ClauseBindKindAttr bind_kind, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(bind_kind)>(bind_kind), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<LoopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LoopOp LoopOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::omp::ClauseBindKindAttr bind_kind, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(bind_kind)>(bind_kind), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
}
|
|
|
|
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();
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<LoopOp::Properties>();
|
|
::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<LoopOp>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(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&>(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);
|
|
}
|
|
|
|
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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<LoopOp>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult LoopOp::verifyInvariantsImpl() {
|
|
auto tblgen_bind_kind = getProperties().bind_kind; (void)tblgen_bind_kind;
|
|
auto tblgen_order = getProperties().order; (void)tblgen_order;
|
|
auto tblgen_order_mod = getProperties().order_mod; (void)tblgen_order_mod;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_reduction_byref = getProperties().reduction_byref; (void)tblgen_reduction_byref;
|
|
auto tblgen_reduction_mod = getProperties().reduction_mod; (void)tblgen_reduction_mod;
|
|
auto tblgen_reduction_syms = getProperties().reduction_syms; (void)tblgen_reduction_syms;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps18(*this, tblgen_bind_kind, "bind_kind")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_private_syms, "private_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_private_needs_barrier, "private_needs_barrier")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps12(*this, tblgen_order, "order")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps13(*this, tblgen_order_mod, "order_mod")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps19(*this, tblgen_reduction_mod, "reduction_mod")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(*this, tblgen_reduction_byref, "reduction_byref")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_reduction_syms, "reduction_syms")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*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_OpenMPOps2(*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::omp::ClauseBindKindAttr bind_kindAttr;
|
|
::mlir::omp::ClauseOrderKindAttr orderAttr;
|
|
::mlir::omp::OrderModifierAttr order_modAttr;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> private_varsOperands;
|
|
::llvm::SMLoc private_varsOperandsLoc;
|
|
(void)private_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> private_varsTypes;
|
|
::mlir::ArrayAttr private_symsAttr;
|
|
::mlir::UnitAttr private_needs_barrierAttr;
|
|
::mlir::omp::ReductionModifierAttr reduction_modAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> reduction_varsOperands;
|
|
::llvm::SMLoc reduction_varsOperandsLoc;
|
|
(void)reduction_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> reduction_varsTypes;
|
|
::mlir::DenseBoolArrayAttr reduction_byrefAttr;
|
|
::mlir::ArrayAttr reduction_symsAttr;
|
|
bool bindClause = false;
|
|
bool orderClause = 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 = parseClauseAttr(parser, bind_kindAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (bind_kindAttr)
|
|
result.getOrAddProperties<LoopOp::Properties>().bind_kind = bind_kindAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("order"))) {
|
|
|
|
if (orderClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`order` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
orderClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseOrderClause(parser, orderAttr, order_modAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (orderAttr)
|
|
result.getOrAddProperties<LoopOp::Properties>().order = orderAttr;
|
|
if (order_modAttr)
|
|
result.getOrAddProperties<LoopOp::Properties>().order_mod = order_modAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
{
|
|
private_varsOperandsLoc = parser.getCurrentLocation();
|
|
reduction_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parsePrivateReductionRegion(parser, *regionRegion, private_varsOperands, private_varsTypes, private_symsAttr, private_needs_barrierAttr, reduction_modAttr, reduction_varsOperands, reduction_varsTypes, reduction_byrefAttr, reduction_symsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (private_symsAttr)
|
|
result.getOrAddProperties<LoopOp::Properties>().private_syms = private_symsAttr;
|
|
if (private_needs_barrierAttr)
|
|
result.getOrAddProperties<LoopOp::Properties>().private_needs_barrier = private_needs_barrierAttr;
|
|
if (reduction_modAttr)
|
|
result.getOrAddProperties<LoopOp::Properties>().reduction_mod = reduction_modAttr;
|
|
if (reduction_byrefAttr)
|
|
result.getOrAddProperties<LoopOp::Properties>().reduction_byref = reduction_byrefAttr;
|
|
if (reduction_symsAttr)
|
|
result.getOrAddProperties<LoopOp::Properties>().reduction_syms = reduction_symsAttr;
|
|
}
|
|
{
|
|
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<int32_t>({static_cast<int32_t>(private_varsOperands.size()), static_cast<int32_t>(reduction_varsOperands.size())}), result.getOrAddProperties<LoopOp::Properties>().operandSegmentSizes.begin());
|
|
if (parser.resolveOperands(private_varsOperands, private_varsTypes, private_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(reduction_varsOperands, reduction_varsTypes, reduction_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void LoopOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || (getBindKindAttr())) {
|
|
_odsPrinter << ' ' << "bind";
|
|
_odsPrinter << "(";
|
|
printClauseAttr(_odsPrinter, *this, getBindKindAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getOrderAttr()) || (getOrderModAttr())) {
|
|
_odsPrinter << ' ' << "order";
|
|
_odsPrinter << "(";
|
|
printOrderClause(_odsPrinter, *this, getOrderAttr(), getOrderModAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ';
|
|
printPrivateReductionRegion(_odsPrinter, *this, getRegion(), getPrivateVars(), getPrivateVars().getTypes(), getPrivateSymsAttr(), getPrivateNeedsBarrierAttr(), getReductionModAttr(), getReductionVars(), getReductionVars().getTypes(), getReductionByrefAttr(), getReductionSymsAttr());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("bind_kind");
|
|
elidedAttrs.push_back("order");
|
|
elidedAttrs.push_back("order_mod");
|
|
elidedAttrs.push_back("private_syms");
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
elidedAttrs.push_back("reduction_mod");
|
|
elidedAttrs.push_back("reduction_byref");
|
|
elidedAttrs.push_back("reduction_syms");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getPrivateNeedsBarrierAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::LoopOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::LoopOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::MapBoundsOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
MapBoundsOpGenericAdaptorBase::MapBoundsOpGenericAdaptorBase(MapBoundsOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> MapBoundsOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::BoolAttr MapBoundsOpGenericAdaptorBase::getStrideInBytesAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().stride_in_bytes);
|
|
return attr;
|
|
}
|
|
|
|
bool MapBoundsOpGenericAdaptorBase::getStrideInBytes() {
|
|
auto attr = getStrideInBytesAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
MapBoundsOpAdaptor::MapBoundsOpAdaptor(MapBoundsOp op) : MapBoundsOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult MapBoundsOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_stride_in_bytes = getProperties().stride_in_bytes; (void)tblgen_stride_in_bytes;
|
|
|
|
if (tblgen_stride_in_bytes && !((::llvm::isa<::mlir::BoolAttr>(tblgen_stride_in_bytes))))
|
|
return emitError(loc, "'omp.map.bounds' op attribute 'stride_in_bytes' failed to satisfy constraint: bool attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> MapBoundsOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange MapBoundsOp::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 MapBoundsOp::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 MapBoundsOp::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 MapBoundsOp::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 MapBoundsOp::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 MapBoundsOp::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.stride_in_bytes;
|
|
auto attr = dict.get("stride_in_bytes");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `stride_in_bytes` 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 MapBoundsOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.stride_in_bytes;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("stride_in_bytes",
|
|
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 MapBoundsOp::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.stride_in_bytes.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> MapBoundsOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "stride_in_bytes")
|
|
return prop.stride_in_bytes;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void MapBoundsOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "stride_in_bytes") {
|
|
prop.stride_in_bytes = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.stride_in_bytes)>>(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 MapBoundsOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.stride_in_bytes) attrs.append("stride_in_bytes", prop.stride_in_bytes);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult MapBoundsOp::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_OpenMPOps21(attr, "stride_in_bytes", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MapBoundsOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.stride_in_bytes)))
|
|
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 MapBoundsOp::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.stride_in_bytes);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
bool MapBoundsOp::getStrideInBytes() {
|
|
auto attr = getStrideInBytesAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void MapBoundsOp::setStrideInBytes(bool attrValue) {
|
|
getProperties().stride_in_bytes = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue);
|
|
}
|
|
|
|
void MapBoundsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, /*optional*/::mlir::Value lower_bound, /*optional*/::mlir::Value upper_bound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, ::mlir::BoolAttr stride_in_bytes, /*optional*/::mlir::Value start_idx) {
|
|
if (lower_bound)
|
|
odsState.addOperands(lower_bound);
|
|
if (upper_bound)
|
|
odsState.addOperands(upper_bound);
|
|
if (extent)
|
|
odsState.addOperands(extent);
|
|
if (stride)
|
|
odsState.addOperands(stride);
|
|
if (start_idx)
|
|
odsState.addOperands(start_idx);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({(lower_bound ? 1 : 0), (upper_bound ? 1 : 0), (extent ? 1 : 0), (stride ? 1 : 0), (start_idx ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (stride_in_bytes) {
|
|
odsState.getOrAddProperties<Properties>().stride_in_bytes = stride_in_bytes;
|
|
}
|
|
odsState.addTypes(result);
|
|
}
|
|
|
|
MapBoundsOp MapBoundsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, /*optional*/::mlir::Value lower_bound, /*optional*/::mlir::Value upper_bound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, ::mlir::BoolAttr stride_in_bytes, /*optional*/::mlir::Value start_idx) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(lower_bound)>(lower_bound), std::forward<decltype(upper_bound)>(upper_bound), std::forward<decltype(extent)>(extent), std::forward<decltype(stride)>(stride), std::forward<decltype(stride_in_bytes)>(stride_in_bytes), std::forward<decltype(start_idx)>(start_idx));
|
|
auto __res__ = ::llvm::dyn_cast<MapBoundsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MapBoundsOp MapBoundsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, /*optional*/::mlir::Value lower_bound, /*optional*/::mlir::Value upper_bound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, ::mlir::BoolAttr stride_in_bytes, /*optional*/::mlir::Value start_idx) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(lower_bound)>(lower_bound), std::forward<decltype(upper_bound)>(upper_bound), std::forward<decltype(extent)>(extent), std::forward<decltype(stride)>(stride), std::forward<decltype(stride_in_bytes)>(stride_in_bytes), std::forward<decltype(start_idx)>(start_idx));
|
|
}
|
|
|
|
void MapBoundsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value lower_bound, /*optional*/::mlir::Value upper_bound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, ::mlir::BoolAttr stride_in_bytes, /*optional*/::mlir::Value start_idx) {
|
|
if (lower_bound)
|
|
odsState.addOperands(lower_bound);
|
|
if (upper_bound)
|
|
odsState.addOperands(upper_bound);
|
|
if (extent)
|
|
odsState.addOperands(extent);
|
|
if (stride)
|
|
odsState.addOperands(stride);
|
|
if (start_idx)
|
|
odsState.addOperands(start_idx);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({(lower_bound ? 1 : 0), (upper_bound ? 1 : 0), (extent ? 1 : 0), (stride ? 1 : 0), (start_idx ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (stride_in_bytes) {
|
|
odsState.getOrAddProperties<Properties>().stride_in_bytes = stride_in_bytes;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MapBoundsOp MapBoundsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value lower_bound, /*optional*/::mlir::Value upper_bound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, ::mlir::BoolAttr stride_in_bytes, /*optional*/::mlir::Value start_idx) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(lower_bound)>(lower_bound), std::forward<decltype(upper_bound)>(upper_bound), std::forward<decltype(extent)>(extent), std::forward<decltype(stride)>(stride), std::forward<decltype(stride_in_bytes)>(stride_in_bytes), std::forward<decltype(start_idx)>(start_idx));
|
|
auto __res__ = ::llvm::dyn_cast<MapBoundsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MapBoundsOp MapBoundsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value lower_bound, /*optional*/::mlir::Value upper_bound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, ::mlir::BoolAttr stride_in_bytes, /*optional*/::mlir::Value start_idx) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(lower_bound)>(lower_bound), std::forward<decltype(upper_bound)>(upper_bound), std::forward<decltype(extent)>(extent), std::forward<decltype(stride)>(stride), std::forward<decltype(stride_in_bytes)>(stride_in_bytes), std::forward<decltype(start_idx)>(start_idx));
|
|
}
|
|
|
|
void MapBoundsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, /*optional*/::mlir::Value lower_bound, /*optional*/::mlir::Value upper_bound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, bool stride_in_bytes, /*optional*/::mlir::Value start_idx) {
|
|
if (lower_bound)
|
|
odsState.addOperands(lower_bound);
|
|
if (upper_bound)
|
|
odsState.addOperands(upper_bound);
|
|
if (extent)
|
|
odsState.addOperands(extent);
|
|
if (stride)
|
|
odsState.addOperands(stride);
|
|
if (start_idx)
|
|
odsState.addOperands(start_idx);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({(lower_bound ? 1 : 0), (upper_bound ? 1 : 0), (extent ? 1 : 0), (stride ? 1 : 0), (start_idx ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
odsState.getOrAddProperties<Properties>().stride_in_bytes = odsBuilder.getBoolAttr(stride_in_bytes);
|
|
odsState.addTypes(result);
|
|
}
|
|
|
|
MapBoundsOp MapBoundsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, /*optional*/::mlir::Value lower_bound, /*optional*/::mlir::Value upper_bound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, bool stride_in_bytes, /*optional*/::mlir::Value start_idx) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(lower_bound)>(lower_bound), std::forward<decltype(upper_bound)>(upper_bound), std::forward<decltype(extent)>(extent), std::forward<decltype(stride)>(stride), std::forward<decltype(stride_in_bytes)>(stride_in_bytes), std::forward<decltype(start_idx)>(start_idx));
|
|
auto __res__ = ::llvm::dyn_cast<MapBoundsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MapBoundsOp MapBoundsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, /*optional*/::mlir::Value lower_bound, /*optional*/::mlir::Value upper_bound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, bool stride_in_bytes, /*optional*/::mlir::Value start_idx) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(lower_bound)>(lower_bound), std::forward<decltype(upper_bound)>(upper_bound), std::forward<decltype(extent)>(extent), std::forward<decltype(stride)>(stride), std::forward<decltype(stride_in_bytes)>(stride_in_bytes), std::forward<decltype(start_idx)>(start_idx));
|
|
}
|
|
|
|
void MapBoundsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value lower_bound, /*optional*/::mlir::Value upper_bound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, bool stride_in_bytes, /*optional*/::mlir::Value start_idx) {
|
|
if (lower_bound)
|
|
odsState.addOperands(lower_bound);
|
|
if (upper_bound)
|
|
odsState.addOperands(upper_bound);
|
|
if (extent)
|
|
odsState.addOperands(extent);
|
|
if (stride)
|
|
odsState.addOperands(stride);
|
|
if (start_idx)
|
|
odsState.addOperands(start_idx);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({(lower_bound ? 1 : 0), (upper_bound ? 1 : 0), (extent ? 1 : 0), (stride ? 1 : 0), (start_idx ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
odsState.getOrAddProperties<Properties>().stride_in_bytes = odsBuilder.getBoolAttr(stride_in_bytes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MapBoundsOp MapBoundsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value lower_bound, /*optional*/::mlir::Value upper_bound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, bool stride_in_bytes, /*optional*/::mlir::Value start_idx) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(lower_bound)>(lower_bound), std::forward<decltype(upper_bound)>(upper_bound), std::forward<decltype(extent)>(extent), std::forward<decltype(stride)>(stride), std::forward<decltype(stride_in_bytes)>(stride_in_bytes), std::forward<decltype(start_idx)>(start_idx));
|
|
auto __res__ = ::llvm::dyn_cast<MapBoundsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MapBoundsOp MapBoundsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value lower_bound, /*optional*/::mlir::Value upper_bound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, bool stride_in_bytes, /*optional*/::mlir::Value start_idx) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(lower_bound)>(lower_bound), std::forward<decltype(upper_bound)>(upper_bound), std::forward<decltype(extent)>(extent), std::forward<decltype(stride)>(stride), std::forward<decltype(stride_in_bytes)>(stride_in_bytes), std::forward<decltype(start_idx)>(start_idx));
|
|
}
|
|
|
|
void MapBoundsOp::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<MapBoundsOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
MapBoundsOp MapBoundsOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<MapBoundsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MapBoundsOp MapBoundsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void MapBoundsOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MapBoundsOp MapBoundsOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<MapBoundsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MapBoundsOp MapBoundsOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
void MapBoundsOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) {
|
|
::mlir::Builder odsBuilder(opName.getContext());
|
|
if (!properties.stride_in_bytes)
|
|
properties.stride_in_bytes = odsBuilder.getBoolAttr(false);
|
|
}
|
|
|
|
::llvm::LogicalResult MapBoundsOp::verifyInvariantsImpl() {
|
|
auto tblgen_stride_in_bytes = getProperties().stride_in_bytes; (void)tblgen_stride_in_bytes;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps21(*this, tblgen_stride_in_bytes, "stride_in_bytes")))
|
|
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_OpenMPOps2(*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_OpenMPOps2(*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_OpenMPOps2(*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_OpenMPOps2(*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_OpenMPOps2(*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_OpenMPOps16(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MapBoundsOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult MapBoundsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> lower_boundOperands;
|
|
::llvm::SMLoc lower_boundOperandsLoc;
|
|
(void)lower_boundOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> lower_boundTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> upper_boundOperands;
|
|
::llvm::SMLoc upper_boundOperandsLoc;
|
|
(void)upper_boundOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> upper_boundTypes;
|
|
::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> start_idxOperands;
|
|
::llvm::SMLoc start_idxOperandsLoc;
|
|
(void)start_idxOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> start_idxTypes;
|
|
bool lower_boundClause = false;
|
|
bool upper_boundClause = false;
|
|
bool extentClause = false;
|
|
bool strideClause = false;
|
|
bool start_idxClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("lower_bound"))) {
|
|
|
|
if (lower_boundClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`lower_bound` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
lower_boundClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
lower_boundOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
lower_boundOperands.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();
|
|
lower_boundTypes.push_back(optionalType);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("upper_bound"))) {
|
|
|
|
if (upper_boundClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`upper_bound` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
upper_boundClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
upper_boundOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
upper_boundOperands.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();
|
|
upper_boundTypes.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("start_idx"))) {
|
|
|
|
if (start_idxClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`start_idx` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
start_idxClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
start_idxOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
start_idxOperands.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();
|
|
start_idxTypes.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<int32_t>({static_cast<int32_t>(lower_boundOperands.size()), static_cast<int32_t>(upper_boundOperands.size()), static_cast<int32_t>(extentOperands.size()), static_cast<int32_t>(strideOperands.size()), static_cast<int32_t>(start_idxOperands.size())}), result.getOrAddProperties<MapBoundsOp::Properties>().operandSegmentSizes.begin());
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::omp::MapBoundsType>();
|
|
result.addTypes(odsBuildableType0);
|
|
if (!lower_boundOperands.empty()) {
|
|
if (parser.resolveOperands(lower_boundOperands, lower_boundTypes, lower_boundOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (!upper_boundOperands.empty()) {
|
|
if (parser.resolveOperands(upper_boundOperands, upper_boundTypes, upper_boundOperandsLoc, 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 (!start_idxOperands.empty()) {
|
|
if (parser.resolveOperands(start_idxOperands, start_idxTypes, start_idxOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MapBoundsOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getLowerBound()) {
|
|
_odsPrinter << ' ' << "lower_bound";
|
|
_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 << ' ' << "upper_bound";
|
|
_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 << ' ' << "start_idx";
|
|
_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("stride_in_bytes");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
void MapBoundsOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::MapBoundsOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::MapBoundsOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::MapInfoOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
MapInfoOpGenericAdaptorBase::MapInfoOpGenericAdaptorBase(MapInfoOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> MapInfoOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::Type MapInfoOpGenericAdaptorBase::getVarPtrType() {
|
|
auto attr = getVarPtrTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::mlir::omp::ClauseMapFlags MapInfoOpGenericAdaptorBase::getMapType() {
|
|
auto attr = getMapTypeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::mlir::omp::VariableCaptureKind MapInfoOpGenericAdaptorBase::getMapCaptureType() {
|
|
auto attr = getMapCaptureTypeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::std::optional<::mlir::Type> MapInfoOpGenericAdaptorBase::getVarPtrPtrType() {
|
|
auto attr = getVarPtrPtrTypeAttr();
|
|
return attr ? ::std::optional<::mlir::Type>(::llvm::cast<::mlir::Type>(attr.getValue())) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > MapInfoOpGenericAdaptorBase::getMembersIndex() {
|
|
auto attr = getMembersIndexAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::llvm::StringRef > MapInfoOpGenericAdaptorBase::getMapperId() {
|
|
auto attr = getMapperIdAttr();
|
|
return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::llvm::StringRef > MapInfoOpGenericAdaptorBase::getName() {
|
|
auto attr = getNameAttr();
|
|
return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::BoolAttr MapInfoOpGenericAdaptorBase::getPartialMapAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().partial_map);
|
|
return attr;
|
|
}
|
|
|
|
bool MapInfoOpGenericAdaptorBase::getPartialMap() {
|
|
auto attr = getPartialMapAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
MapInfoOpAdaptor::MapInfoOpAdaptor(MapInfoOp op) : MapInfoOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult MapInfoOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_map_capture_type = getProperties().map_capture_type; (void)tblgen_map_capture_type;
|
|
if (!tblgen_map_capture_type) return emitError(loc, "'omp.map.info' op requires attribute 'map_capture_type'");
|
|
auto tblgen_map_type = getProperties().map_type; (void)tblgen_map_type;
|
|
if (!tblgen_map_type) return emitError(loc, "'omp.map.info' op requires attribute 'map_type'");
|
|
auto tblgen_mapper_id = getProperties().mapper_id; (void)tblgen_mapper_id;
|
|
auto tblgen_members_index = getProperties().members_index; (void)tblgen_members_index;
|
|
auto tblgen_name = getProperties().name; (void)tblgen_name;
|
|
auto tblgen_partial_map = getProperties().partial_map; (void)tblgen_partial_map;
|
|
auto tblgen_var_ptr_ptr_type = getProperties().var_ptr_ptr_type; (void)tblgen_var_ptr_ptr_type;
|
|
auto tblgen_var_ptr_type = getProperties().var_ptr_type; (void)tblgen_var_ptr_type;
|
|
if (!tblgen_var_ptr_type) return emitError(loc, "'omp.map.info' op requires attribute 'var_ptr_type'");
|
|
|
|
if (tblgen_var_ptr_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_var_ptr_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_var_ptr_type).getValue()))) && ((true))))
|
|
return emitError(loc, "'omp.map.info' op attribute 'var_ptr_type' failed to satisfy constraint: any type attribute");
|
|
|
|
if (tblgen_map_type && !((::llvm::isa<::mlir::omp::ClauseMapFlagsAttr>(tblgen_map_type))))
|
|
return emitError(loc, "'omp.map.info' op attribute 'map_type' failed to satisfy constraint: Map types and modifiers tied to data maps");
|
|
|
|
if (tblgen_map_capture_type && !((::llvm::isa<::mlir::omp::VariableCaptureKindAttr>(tblgen_map_capture_type))))
|
|
return emitError(loc, "'omp.map.info' op attribute 'map_capture_type' failed to satisfy constraint: variable capture kind");
|
|
|
|
if (tblgen_var_ptr_ptr_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_var_ptr_ptr_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_var_ptr_ptr_type).getValue()))) && ((true))))
|
|
return emitError(loc, "'omp.map.info' op attribute 'var_ptr_ptr_type' failed to satisfy constraint: any type attribute");
|
|
|
|
if (tblgen_members_index && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_members_index))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_members_index), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); }))); }))))
|
|
return emitError(loc, "'omp.map.info' op attribute 'members_index' failed to satisfy constraint: Array of 64-bit integer array attributes");
|
|
|
|
if (tblgen_mapper_id && !((::llvm::isa<::mlir::FlatSymbolRefAttr>(tblgen_mapper_id))))
|
|
return emitError(loc, "'omp.map.info' op attribute 'mapper_id' failed to satisfy constraint: flat symbol reference attribute");
|
|
|
|
if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name))))
|
|
return emitError(loc, "'omp.map.info' op attribute 'name' failed to satisfy constraint: string attribute");
|
|
|
|
if (tblgen_partial_map && !((::llvm::isa<::mlir::BoolAttr>(tblgen_partial_map))))
|
|
return emitError(loc, "'omp.map.info' op attribute 'partial_map' failed to satisfy constraint: bool attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> MapInfoOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange MapInfoOp::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 MapInfoOp::getMembersMutable() {
|
|
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 MapInfoOp::getBoundsMutable() {
|
|
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 MapInfoOp::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.map_capture_type;
|
|
auto attr = dict.get("map_capture_type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `map_capture_type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.map_type;
|
|
auto attr = dict.get("map_type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `map_type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.mapper_id;
|
|
auto attr = dict.get("mapper_id");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `mapper_id` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.members_index;
|
|
auto attr = dict.get("members_index");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `members_index` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.name;
|
|
auto attr = dict.get("name");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `name` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.partial_map;
|
|
auto attr = dict.get("partial_map");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `partial_map` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.var_ptr_ptr_type;
|
|
auto attr = dict.get("var_ptr_ptr_type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `var_ptr_ptr_type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.var_ptr_type;
|
|
auto attr = dict.get("var_ptr_type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `var_ptr_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 MapInfoOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.map_capture_type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("map_capture_type",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.map_type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("map_type",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.mapper_id;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("mapper_id",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.members_index;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("members_index",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.name;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("name",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.partial_map;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("partial_map",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.var_ptr_ptr_type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("var_ptr_ptr_type",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.var_ptr_type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("var_ptr_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 MapInfoOp::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.map_capture_type.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.map_type.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.mapper_id.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.members_index.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.name.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.partial_map.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.var_ptr_ptr_type.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.var_ptr_type.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> MapInfoOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "map_capture_type")
|
|
return prop.map_capture_type;
|
|
|
|
if (name == "map_type")
|
|
return prop.map_type;
|
|
|
|
if (name == "mapper_id")
|
|
return prop.mapper_id;
|
|
|
|
if (name == "members_index")
|
|
return prop.members_index;
|
|
|
|
if (name == "name")
|
|
return prop.name;
|
|
|
|
if (name == "partial_map")
|
|
return prop.partial_map;
|
|
|
|
if (name == "var_ptr_ptr_type")
|
|
return prop.var_ptr_ptr_type;
|
|
|
|
if (name == "var_ptr_type")
|
|
return prop.var_ptr_type;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void MapInfoOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "map_capture_type") {
|
|
prop.map_capture_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.map_capture_type)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "map_type") {
|
|
prop.map_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.map_type)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "mapper_id") {
|
|
prop.mapper_id = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.mapper_id)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "members_index") {
|
|
prop.members_index = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.members_index)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "name") {
|
|
prop.name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.name)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "partial_map") {
|
|
prop.partial_map = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.partial_map)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "var_ptr_ptr_type") {
|
|
prop.var_ptr_ptr_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.var_ptr_ptr_type)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "var_ptr_type") {
|
|
prop.var_ptr_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.var_ptr_type)>>(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 MapInfoOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.map_capture_type) attrs.append("map_capture_type", prop.map_capture_type);
|
|
|
|
if (prop.map_type) attrs.append("map_type", prop.map_type);
|
|
|
|
if (prop.mapper_id) attrs.append("mapper_id", prop.mapper_id);
|
|
|
|
if (prop.members_index) attrs.append("members_index", prop.members_index);
|
|
|
|
if (prop.name) attrs.append("name", prop.name);
|
|
|
|
if (prop.partial_map) attrs.append("partial_map", prop.partial_map);
|
|
|
|
if (prop.var_ptr_ptr_type) attrs.append("var_ptr_ptr_type", prop.var_ptr_ptr_type);
|
|
|
|
if (prop.var_ptr_type) attrs.append("var_ptr_type", prop.var_ptr_type);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult MapInfoOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMapCaptureTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps23(attr, "map_capture_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMapTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps22(attr, "map_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMapperIdAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps9(attr, "mapper_id", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMembersIndexAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps24(attr, "members_index", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNameAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps8(attr, "name", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPartialMapAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps21(attr, "partial_map", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getVarPtrPtrTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(attr, "var_ptr_ptr_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getVarPtrTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(attr, "var_ptr_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MapInfoOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.map_capture_type)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.map_type)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.mapper_id)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.members_index)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.partial_map)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.var_ptr_ptr_type)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.var_ptr_type)))
|
|
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 MapInfoOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.map_capture_type);
|
|
writer.writeAttribute(prop.map_type);
|
|
|
|
writer.writeOptionalAttribute(prop.mapper_id);
|
|
|
|
writer.writeOptionalAttribute(prop.members_index);
|
|
|
|
writer.writeOptionalAttribute(prop.name);
|
|
|
|
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
|
|
}
|
|
|
|
writer.writeOptionalAttribute(prop.partial_map);
|
|
|
|
writer.writeOptionalAttribute(prop.var_ptr_ptr_type);
|
|
writer.writeAttribute(prop.var_ptr_type);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
::mlir::Type MapInfoOp::getVarPtrType() {
|
|
auto attr = getVarPtrTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::mlir::omp::ClauseMapFlags MapInfoOp::getMapType() {
|
|
auto attr = getMapTypeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::mlir::omp::VariableCaptureKind MapInfoOp::getMapCaptureType() {
|
|
auto attr = getMapCaptureTypeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::std::optional<::mlir::Type> MapInfoOp::getVarPtrPtrType() {
|
|
auto attr = getVarPtrPtrTypeAttr();
|
|
return attr ? ::std::optional<::mlir::Type>(::llvm::cast<::mlir::Type>(attr.getValue())) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > MapInfoOp::getMembersIndex() {
|
|
auto attr = getMembersIndexAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::llvm::StringRef > MapInfoOp::getMapperId() {
|
|
auto attr = getMapperIdAttr();
|
|
return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::llvm::StringRef > MapInfoOp::getName() {
|
|
auto attr = getNameAttr();
|
|
return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
bool MapInfoOp::getPartialMap() {
|
|
auto attr = getPartialMapAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void MapInfoOp::setVarPtrType(::mlir::Type attrValue) {
|
|
getProperties().var_ptr_type = ::mlir::TypeAttr::get(attrValue);
|
|
}
|
|
|
|
void MapInfoOp::setMapType(::mlir::omp::ClauseMapFlags attrValue) {
|
|
getProperties().map_type = ::mlir::omp::ClauseMapFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void MapInfoOp::setMapCaptureType(::mlir::omp::VariableCaptureKind attrValue) {
|
|
getProperties().map_capture_type = ::mlir::omp::VariableCaptureKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void MapInfoOp::setVarPtrPtrType(::std::optional<::mlir::Type> attrValue) {
|
|
auto &odsProp = getProperties().var_ptr_ptr_type;
|
|
if (attrValue)
|
|
odsProp = ::mlir::TypeAttr::get(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void MapInfoOp::setMapperId(::std::optional<::llvm::StringRef> attrValue) {
|
|
auto &odsProp = getProperties().mapper_id;
|
|
if (attrValue)
|
|
odsProp = ::mlir::SymbolRefAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void MapInfoOp::setName(::std::optional<::llvm::StringRef> attrValue) {
|
|
auto &odsProp = getProperties().name;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void MapInfoOp::setPartialMap(bool attrValue) {
|
|
getProperties().partial_map = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue);
|
|
}
|
|
|
|
void MapInfoOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type omp_ptr, ::mlir::Value var_ptr, ::mlir::TypeAttr var_ptr_type, ::mlir::omp::ClauseMapFlagsAttr map_type, ::mlir::omp::VariableCaptureKindAttr map_capture_type, /*optional*/::mlir::Value var_ptr_ptr, /*optional*/::mlir::TypeAttr var_ptr_ptr_type, ::mlir::ValueRange members, /*optional*/::mlir::ArrayAttr members_index, ::mlir::ValueRange bounds, /*optional*/::mlir::FlatSymbolRefAttr mapper_id, /*optional*/::mlir::StringAttr name, ::mlir::BoolAttr partial_map) {
|
|
odsState.addOperands(var_ptr);
|
|
if (var_ptr_ptr)
|
|
odsState.addOperands(var_ptr_ptr);
|
|
odsState.addOperands(members);
|
|
odsState.addOperands(bounds);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({1, (var_ptr_ptr ? 1 : 0), static_cast<int32_t>(members.size()), static_cast<int32_t>(bounds.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
odsState.getOrAddProperties<Properties>().var_ptr_type = var_ptr_type;
|
|
odsState.getOrAddProperties<Properties>().map_type = map_type;
|
|
odsState.getOrAddProperties<Properties>().map_capture_type = map_capture_type;
|
|
if (var_ptr_ptr_type) {
|
|
odsState.getOrAddProperties<Properties>().var_ptr_ptr_type = var_ptr_ptr_type;
|
|
}
|
|
if (members_index) {
|
|
odsState.getOrAddProperties<Properties>().members_index = members_index;
|
|
}
|
|
if (mapper_id) {
|
|
odsState.getOrAddProperties<Properties>().mapper_id = mapper_id;
|
|
}
|
|
if (name) {
|
|
odsState.getOrAddProperties<Properties>().name = name;
|
|
}
|
|
if (partial_map) {
|
|
odsState.getOrAddProperties<Properties>().partial_map = partial_map;
|
|
}
|
|
odsState.addTypes(omp_ptr);
|
|
}
|
|
|
|
MapInfoOp MapInfoOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type omp_ptr, ::mlir::Value var_ptr, ::mlir::TypeAttr var_ptr_type, ::mlir::omp::ClauseMapFlagsAttr map_type, ::mlir::omp::VariableCaptureKindAttr map_capture_type, /*optional*/::mlir::Value var_ptr_ptr, /*optional*/::mlir::TypeAttr var_ptr_ptr_type, ::mlir::ValueRange members, /*optional*/::mlir::ArrayAttr members_index, ::mlir::ValueRange bounds, /*optional*/::mlir::FlatSymbolRefAttr mapper_id, /*optional*/::mlir::StringAttr name, ::mlir::BoolAttr partial_map) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(omp_ptr)>(omp_ptr), std::forward<decltype(var_ptr)>(var_ptr), std::forward<decltype(var_ptr_type)>(var_ptr_type), std::forward<decltype(map_type)>(map_type), std::forward<decltype(map_capture_type)>(map_capture_type), std::forward<decltype(var_ptr_ptr)>(var_ptr_ptr), std::forward<decltype(var_ptr_ptr_type)>(var_ptr_ptr_type), std::forward<decltype(members)>(members), std::forward<decltype(members_index)>(members_index), std::forward<decltype(bounds)>(bounds), std::forward<decltype(mapper_id)>(mapper_id), std::forward<decltype(name)>(name), std::forward<decltype(partial_map)>(partial_map));
|
|
auto __res__ = ::llvm::dyn_cast<MapInfoOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MapInfoOp MapInfoOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type omp_ptr, ::mlir::Value var_ptr, ::mlir::TypeAttr var_ptr_type, ::mlir::omp::ClauseMapFlagsAttr map_type, ::mlir::omp::VariableCaptureKindAttr map_capture_type, /*optional*/::mlir::Value var_ptr_ptr, /*optional*/::mlir::TypeAttr var_ptr_ptr_type, ::mlir::ValueRange members, /*optional*/::mlir::ArrayAttr members_index, ::mlir::ValueRange bounds, /*optional*/::mlir::FlatSymbolRefAttr mapper_id, /*optional*/::mlir::StringAttr name, ::mlir::BoolAttr partial_map) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(omp_ptr)>(omp_ptr), std::forward<decltype(var_ptr)>(var_ptr), std::forward<decltype(var_ptr_type)>(var_ptr_type), std::forward<decltype(map_type)>(map_type), std::forward<decltype(map_capture_type)>(map_capture_type), std::forward<decltype(var_ptr_ptr)>(var_ptr_ptr), std::forward<decltype(var_ptr_ptr_type)>(var_ptr_ptr_type), std::forward<decltype(members)>(members), std::forward<decltype(members_index)>(members_index), std::forward<decltype(bounds)>(bounds), std::forward<decltype(mapper_id)>(mapper_id), std::forward<decltype(name)>(name), std::forward<decltype(partial_map)>(partial_map));
|
|
}
|
|
|
|
void MapInfoOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var_ptr, ::mlir::TypeAttr var_ptr_type, ::mlir::omp::ClauseMapFlagsAttr map_type, ::mlir::omp::VariableCaptureKindAttr map_capture_type, /*optional*/::mlir::Value var_ptr_ptr, /*optional*/::mlir::TypeAttr var_ptr_ptr_type, ::mlir::ValueRange members, /*optional*/::mlir::ArrayAttr members_index, ::mlir::ValueRange bounds, /*optional*/::mlir::FlatSymbolRefAttr mapper_id, /*optional*/::mlir::StringAttr name, ::mlir::BoolAttr partial_map) {
|
|
odsState.addOperands(var_ptr);
|
|
if (var_ptr_ptr)
|
|
odsState.addOperands(var_ptr_ptr);
|
|
odsState.addOperands(members);
|
|
odsState.addOperands(bounds);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({1, (var_ptr_ptr ? 1 : 0), static_cast<int32_t>(members.size()), static_cast<int32_t>(bounds.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
odsState.getOrAddProperties<Properties>().var_ptr_type = var_ptr_type;
|
|
odsState.getOrAddProperties<Properties>().map_type = map_type;
|
|
odsState.getOrAddProperties<Properties>().map_capture_type = map_capture_type;
|
|
if (var_ptr_ptr_type) {
|
|
odsState.getOrAddProperties<Properties>().var_ptr_ptr_type = var_ptr_ptr_type;
|
|
}
|
|
if (members_index) {
|
|
odsState.getOrAddProperties<Properties>().members_index = members_index;
|
|
}
|
|
if (mapper_id) {
|
|
odsState.getOrAddProperties<Properties>().mapper_id = mapper_id;
|
|
}
|
|
if (name) {
|
|
odsState.getOrAddProperties<Properties>().name = name;
|
|
}
|
|
if (partial_map) {
|
|
odsState.getOrAddProperties<Properties>().partial_map = partial_map;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MapInfoOp MapInfoOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var_ptr, ::mlir::TypeAttr var_ptr_type, ::mlir::omp::ClauseMapFlagsAttr map_type, ::mlir::omp::VariableCaptureKindAttr map_capture_type, /*optional*/::mlir::Value var_ptr_ptr, /*optional*/::mlir::TypeAttr var_ptr_ptr_type, ::mlir::ValueRange members, /*optional*/::mlir::ArrayAttr members_index, ::mlir::ValueRange bounds, /*optional*/::mlir::FlatSymbolRefAttr mapper_id, /*optional*/::mlir::StringAttr name, ::mlir::BoolAttr partial_map) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(var_ptr)>(var_ptr), std::forward<decltype(var_ptr_type)>(var_ptr_type), std::forward<decltype(map_type)>(map_type), std::forward<decltype(map_capture_type)>(map_capture_type), std::forward<decltype(var_ptr_ptr)>(var_ptr_ptr), std::forward<decltype(var_ptr_ptr_type)>(var_ptr_ptr_type), std::forward<decltype(members)>(members), std::forward<decltype(members_index)>(members_index), std::forward<decltype(bounds)>(bounds), std::forward<decltype(mapper_id)>(mapper_id), std::forward<decltype(name)>(name), std::forward<decltype(partial_map)>(partial_map));
|
|
auto __res__ = ::llvm::dyn_cast<MapInfoOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MapInfoOp MapInfoOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var_ptr, ::mlir::TypeAttr var_ptr_type, ::mlir::omp::ClauseMapFlagsAttr map_type, ::mlir::omp::VariableCaptureKindAttr map_capture_type, /*optional*/::mlir::Value var_ptr_ptr, /*optional*/::mlir::TypeAttr var_ptr_ptr_type, ::mlir::ValueRange members, /*optional*/::mlir::ArrayAttr members_index, ::mlir::ValueRange bounds, /*optional*/::mlir::FlatSymbolRefAttr mapper_id, /*optional*/::mlir::StringAttr name, ::mlir::BoolAttr partial_map) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(var_ptr)>(var_ptr), std::forward<decltype(var_ptr_type)>(var_ptr_type), std::forward<decltype(map_type)>(map_type), std::forward<decltype(map_capture_type)>(map_capture_type), std::forward<decltype(var_ptr_ptr)>(var_ptr_ptr), std::forward<decltype(var_ptr_ptr_type)>(var_ptr_ptr_type), std::forward<decltype(members)>(members), std::forward<decltype(members_index)>(members_index), std::forward<decltype(bounds)>(bounds), std::forward<decltype(mapper_id)>(mapper_id), std::forward<decltype(name)>(name), std::forward<decltype(partial_map)>(partial_map));
|
|
}
|
|
|
|
void MapInfoOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type omp_ptr, ::mlir::Value var_ptr, ::mlir::Type var_ptr_type, ::mlir::omp::ClauseMapFlags map_type, ::mlir::omp::VariableCaptureKind map_capture_type, /*optional*/::mlir::Value var_ptr_ptr, /*optional*/::mlir::TypeAttr var_ptr_ptr_type, ::mlir::ValueRange members, /*optional*/::mlir::ArrayAttr members_index, ::mlir::ValueRange bounds, /*optional*/::mlir::FlatSymbolRefAttr mapper_id, /*optional*/::mlir::StringAttr name, bool partial_map) {
|
|
odsState.addOperands(var_ptr);
|
|
if (var_ptr_ptr)
|
|
odsState.addOperands(var_ptr_ptr);
|
|
odsState.addOperands(members);
|
|
odsState.addOperands(bounds);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({1, (var_ptr_ptr ? 1 : 0), static_cast<int32_t>(members.size()), static_cast<int32_t>(bounds.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
odsState.getOrAddProperties<Properties>().var_ptr_type = ::mlir::TypeAttr::get(var_ptr_type);
|
|
odsState.getOrAddProperties<Properties>().map_type = ::mlir::omp::ClauseMapFlagsAttr::get(odsBuilder.getContext(), map_type);
|
|
odsState.getOrAddProperties<Properties>().map_capture_type = ::mlir::omp::VariableCaptureKindAttr::get(odsBuilder.getContext(), map_capture_type);
|
|
if (var_ptr_ptr_type) {
|
|
odsState.getOrAddProperties<Properties>().var_ptr_ptr_type = var_ptr_ptr_type;
|
|
}
|
|
if (members_index) {
|
|
odsState.getOrAddProperties<Properties>().members_index = members_index;
|
|
}
|
|
if (mapper_id) {
|
|
odsState.getOrAddProperties<Properties>().mapper_id = mapper_id;
|
|
}
|
|
if (name) {
|
|
odsState.getOrAddProperties<Properties>().name = name;
|
|
}
|
|
odsState.getOrAddProperties<Properties>().partial_map = odsBuilder.getBoolAttr(partial_map);
|
|
odsState.addTypes(omp_ptr);
|
|
}
|
|
|
|
MapInfoOp MapInfoOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type omp_ptr, ::mlir::Value var_ptr, ::mlir::Type var_ptr_type, ::mlir::omp::ClauseMapFlags map_type, ::mlir::omp::VariableCaptureKind map_capture_type, /*optional*/::mlir::Value var_ptr_ptr, /*optional*/::mlir::TypeAttr var_ptr_ptr_type, ::mlir::ValueRange members, /*optional*/::mlir::ArrayAttr members_index, ::mlir::ValueRange bounds, /*optional*/::mlir::FlatSymbolRefAttr mapper_id, /*optional*/::mlir::StringAttr name, bool partial_map) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(omp_ptr)>(omp_ptr), std::forward<decltype(var_ptr)>(var_ptr), std::forward<decltype(var_ptr_type)>(var_ptr_type), std::forward<decltype(map_type)>(map_type), std::forward<decltype(map_capture_type)>(map_capture_type), std::forward<decltype(var_ptr_ptr)>(var_ptr_ptr), std::forward<decltype(var_ptr_ptr_type)>(var_ptr_ptr_type), std::forward<decltype(members)>(members), std::forward<decltype(members_index)>(members_index), std::forward<decltype(bounds)>(bounds), std::forward<decltype(mapper_id)>(mapper_id), std::forward<decltype(name)>(name), std::forward<decltype(partial_map)>(partial_map));
|
|
auto __res__ = ::llvm::dyn_cast<MapInfoOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MapInfoOp MapInfoOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type omp_ptr, ::mlir::Value var_ptr, ::mlir::Type var_ptr_type, ::mlir::omp::ClauseMapFlags map_type, ::mlir::omp::VariableCaptureKind map_capture_type, /*optional*/::mlir::Value var_ptr_ptr, /*optional*/::mlir::TypeAttr var_ptr_ptr_type, ::mlir::ValueRange members, /*optional*/::mlir::ArrayAttr members_index, ::mlir::ValueRange bounds, /*optional*/::mlir::FlatSymbolRefAttr mapper_id, /*optional*/::mlir::StringAttr name, bool partial_map) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(omp_ptr)>(omp_ptr), std::forward<decltype(var_ptr)>(var_ptr), std::forward<decltype(var_ptr_type)>(var_ptr_type), std::forward<decltype(map_type)>(map_type), std::forward<decltype(map_capture_type)>(map_capture_type), std::forward<decltype(var_ptr_ptr)>(var_ptr_ptr), std::forward<decltype(var_ptr_ptr_type)>(var_ptr_ptr_type), std::forward<decltype(members)>(members), std::forward<decltype(members_index)>(members_index), std::forward<decltype(bounds)>(bounds), std::forward<decltype(mapper_id)>(mapper_id), std::forward<decltype(name)>(name), std::forward<decltype(partial_map)>(partial_map));
|
|
}
|
|
|
|
void MapInfoOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var_ptr, ::mlir::Type var_ptr_type, ::mlir::omp::ClauseMapFlags map_type, ::mlir::omp::VariableCaptureKind map_capture_type, /*optional*/::mlir::Value var_ptr_ptr, /*optional*/::mlir::TypeAttr var_ptr_ptr_type, ::mlir::ValueRange members, /*optional*/::mlir::ArrayAttr members_index, ::mlir::ValueRange bounds, /*optional*/::mlir::FlatSymbolRefAttr mapper_id, /*optional*/::mlir::StringAttr name, bool partial_map) {
|
|
odsState.addOperands(var_ptr);
|
|
if (var_ptr_ptr)
|
|
odsState.addOperands(var_ptr_ptr);
|
|
odsState.addOperands(members);
|
|
odsState.addOperands(bounds);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({1, (var_ptr_ptr ? 1 : 0), static_cast<int32_t>(members.size()), static_cast<int32_t>(bounds.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
odsState.getOrAddProperties<Properties>().var_ptr_type = ::mlir::TypeAttr::get(var_ptr_type);
|
|
odsState.getOrAddProperties<Properties>().map_type = ::mlir::omp::ClauseMapFlagsAttr::get(odsBuilder.getContext(), map_type);
|
|
odsState.getOrAddProperties<Properties>().map_capture_type = ::mlir::omp::VariableCaptureKindAttr::get(odsBuilder.getContext(), map_capture_type);
|
|
if (var_ptr_ptr_type) {
|
|
odsState.getOrAddProperties<Properties>().var_ptr_ptr_type = var_ptr_ptr_type;
|
|
}
|
|
if (members_index) {
|
|
odsState.getOrAddProperties<Properties>().members_index = members_index;
|
|
}
|
|
if (mapper_id) {
|
|
odsState.getOrAddProperties<Properties>().mapper_id = mapper_id;
|
|
}
|
|
if (name) {
|
|
odsState.getOrAddProperties<Properties>().name = name;
|
|
}
|
|
odsState.getOrAddProperties<Properties>().partial_map = odsBuilder.getBoolAttr(partial_map);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MapInfoOp MapInfoOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var_ptr, ::mlir::Type var_ptr_type, ::mlir::omp::ClauseMapFlags map_type, ::mlir::omp::VariableCaptureKind map_capture_type, /*optional*/::mlir::Value var_ptr_ptr, /*optional*/::mlir::TypeAttr var_ptr_ptr_type, ::mlir::ValueRange members, /*optional*/::mlir::ArrayAttr members_index, ::mlir::ValueRange bounds, /*optional*/::mlir::FlatSymbolRefAttr mapper_id, /*optional*/::mlir::StringAttr name, bool partial_map) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(var_ptr)>(var_ptr), std::forward<decltype(var_ptr_type)>(var_ptr_type), std::forward<decltype(map_type)>(map_type), std::forward<decltype(map_capture_type)>(map_capture_type), std::forward<decltype(var_ptr_ptr)>(var_ptr_ptr), std::forward<decltype(var_ptr_ptr_type)>(var_ptr_ptr_type), std::forward<decltype(members)>(members), std::forward<decltype(members_index)>(members_index), std::forward<decltype(bounds)>(bounds), std::forward<decltype(mapper_id)>(mapper_id), std::forward<decltype(name)>(name), std::forward<decltype(partial_map)>(partial_map));
|
|
auto __res__ = ::llvm::dyn_cast<MapInfoOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MapInfoOp MapInfoOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var_ptr, ::mlir::Type var_ptr_type, ::mlir::omp::ClauseMapFlags map_type, ::mlir::omp::VariableCaptureKind map_capture_type, /*optional*/::mlir::Value var_ptr_ptr, /*optional*/::mlir::TypeAttr var_ptr_ptr_type, ::mlir::ValueRange members, /*optional*/::mlir::ArrayAttr members_index, ::mlir::ValueRange bounds, /*optional*/::mlir::FlatSymbolRefAttr mapper_id, /*optional*/::mlir::StringAttr name, bool partial_map) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(var_ptr)>(var_ptr), std::forward<decltype(var_ptr_type)>(var_ptr_type), std::forward<decltype(map_type)>(map_type), std::forward<decltype(map_capture_type)>(map_capture_type), std::forward<decltype(var_ptr_ptr)>(var_ptr_ptr), std::forward<decltype(var_ptr_ptr_type)>(var_ptr_ptr_type), std::forward<decltype(members)>(members), std::forward<decltype(members_index)>(members_index), std::forward<decltype(bounds)>(bounds), std::forward<decltype(mapper_id)>(mapper_id), std::forward<decltype(name)>(name), std::forward<decltype(partial_map)>(partial_map));
|
|
}
|
|
|
|
void MapInfoOp::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<MapInfoOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
MapInfoOp MapInfoOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<MapInfoOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MapInfoOp MapInfoOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void MapInfoOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MapInfoOp MapInfoOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<MapInfoOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MapInfoOp MapInfoOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
void MapInfoOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) {
|
|
::mlir::Builder odsBuilder(opName.getContext());
|
|
if (!properties.partial_map)
|
|
properties.partial_map = odsBuilder.getBoolAttr(false);
|
|
}
|
|
|
|
::llvm::LogicalResult MapInfoOp::verifyInvariantsImpl() {
|
|
auto tblgen_map_capture_type = getProperties().map_capture_type; (void)tblgen_map_capture_type;
|
|
if (!tblgen_map_capture_type) return emitOpError("requires attribute 'map_capture_type'");
|
|
auto tblgen_map_type = getProperties().map_type; (void)tblgen_map_type;
|
|
if (!tblgen_map_type) return emitOpError("requires attribute 'map_type'");
|
|
auto tblgen_mapper_id = getProperties().mapper_id; (void)tblgen_mapper_id;
|
|
auto tblgen_members_index = getProperties().members_index; (void)tblgen_members_index;
|
|
auto tblgen_name = getProperties().name; (void)tblgen_name;
|
|
auto tblgen_partial_map = getProperties().partial_map; (void)tblgen_partial_map;
|
|
auto tblgen_var_ptr_ptr_type = getProperties().var_ptr_ptr_type; (void)tblgen_var_ptr_ptr_type;
|
|
auto tblgen_var_ptr_type = getProperties().var_ptr_type; (void)tblgen_var_ptr_type;
|
|
if (!tblgen_var_ptr_type) return emitOpError("requires attribute 'var_ptr_type'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(*this, tblgen_var_ptr_type, "var_ptr_type")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps22(*this, tblgen_map_type, "map_type")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps23(*this, tblgen_map_capture_type, "map_capture_type")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(*this, tblgen_var_ptr_ptr_type, "var_ptr_ptr_type")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps24(*this, tblgen_members_index, "members_index")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps9(*this, tblgen_mapper_id, "mapper_id")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps8(*this, tblgen_name, "name")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps21(*this, tblgen_partial_map, "partial_map")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps1(*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_OpenMPOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps17(*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_OpenMPOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MapInfoOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult MapInfoOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::OpAsmParser::UnresolvedOperand var_ptrRawOperand{};
|
|
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> var_ptrOperands(&var_ptrRawOperand, 1); ::llvm::SMLoc var_ptrOperandsLoc;
|
|
(void)var_ptrOperandsLoc;
|
|
::mlir::Type var_ptrRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> var_ptrTypes(&var_ptrRawType, 1);
|
|
::mlir::TypeAttr var_ptr_typeAttr;
|
|
::mlir::omp::ClauseMapFlagsAttr map_typeAttr;
|
|
::mlir::omp::VariableCaptureKindAttr map_capture_typeAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> var_ptr_ptrOperands;
|
|
::llvm::SMLoc var_ptr_ptrOperandsLoc;
|
|
(void)var_ptr_ptrOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> var_ptr_ptrTypes;
|
|
::mlir::TypeAttr var_ptr_ptr_typeAttr;
|
|
::mlir::FlatSymbolRefAttr mapper_idAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> membersOperands;
|
|
::llvm::SMLoc membersOperandsLoc;
|
|
(void)membersOperandsLoc;
|
|
::mlir::ArrayAttr members_indexAttr;
|
|
::llvm::SmallVector<::mlir::Type, 1> membersTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands;
|
|
::llvm::SMLoc boundsOperandsLoc;
|
|
(void)boundsOperandsLoc;
|
|
::mlir::Type omp_ptrRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> omp_ptrTypes(&omp_ptrRawType, 1);
|
|
if (parser.parseKeyword("var_ptr"))
|
|
return ::mlir::failure();
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
var_ptrOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperand(var_ptrRawOperand))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
::mlir::omp::PointerLikeType type;
|
|
if (parser.parseCustomTypeWithFallback(type))
|
|
return ::mlir::failure();
|
|
var_ptrRawType = type;
|
|
}
|
|
if (parser.parseComma())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseCustomAttributeWithFallback(var_ptr_typeAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
|
|
return ::mlir::failure();
|
|
}
|
|
if (var_ptr_typeAttr) result.getOrAddProperties<MapInfoOp::Properties>().var_ptr_type = var_ptr_typeAttr;
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
if (parser.parseKeyword("map_clauses"))
|
|
return ::mlir::failure();
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseMapClause(parser, map_typeAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
result.getOrAddProperties<MapInfoOp::Properties>().map_type = map_typeAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
if (parser.parseKeyword("capture"))
|
|
return ::mlir::failure();
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseCaptureType(parser, map_capture_typeAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
result.getOrAddProperties<MapInfoOp::Properties>().map_capture_type = map_capture_typeAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
bool var_ptr_ptrClause = false;
|
|
bool mapperClause = false;
|
|
bool membersClause = false;
|
|
bool boundsClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("var_ptr_ptr"))) {
|
|
|
|
if (var_ptr_ptrClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`var_ptr_ptr` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
var_ptr_ptrClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
var_ptr_ptrOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
var_ptr_ptrOperands.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();
|
|
var_ptr_ptrTypes.push_back(optionalType);
|
|
}
|
|
}
|
|
if (parser.parseComma())
|
|
return ::mlir::failure();
|
|
|
|
::mlir::OptionalParseResult parseResultvar_ptr_ptr_typeAttr =
|
|
parser.parseOptionalAttribute(var_ptr_ptr_typeAttr, parser.getBuilder().getType<::mlir::NoneType>());
|
|
if (parseResultvar_ptr_ptr_typeAttr.has_value() && failed(*parseResultvar_ptr_ptr_typeAttr))
|
|
return ::mlir::failure();
|
|
if (parseResultvar_ptr_ptr_typeAttr.has_value() && succeeded(*parseResultvar_ptr_ptr_typeAttr))
|
|
if (var_ptr_ptr_typeAttr) result.getOrAddProperties<MapInfoOp::Properties>().var_ptr_ptr_type = var_ptr_ptr_typeAttr;
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("mapper"))) {
|
|
|
|
if (mapperClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`mapper` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
mapperClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
::mlir::OptionalParseResult parseResultmapper_idAttr =
|
|
parser.parseOptionalAttribute(mapper_idAttr, parser.getBuilder().getType<::mlir::NoneType>());
|
|
if (parseResultmapper_idAttr.has_value() && failed(*parseResultmapper_idAttr))
|
|
return ::mlir::failure();
|
|
if (parseResultmapper_idAttr.has_value() && succeeded(*parseResultmapper_idAttr))
|
|
if (mapper_idAttr) result.getOrAddProperties<MapInfoOp::Properties>().mapper_id = mapper_idAttr;
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("members"))) {
|
|
|
|
if (membersClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`members` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
membersClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
membersOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(membersOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseMembersIndex(parser, members_indexAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (members_indexAttr)
|
|
result.getOrAddProperties<MapInfoOp::Properties>().members_index = members_indexAttr;
|
|
}
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(membersTypes))
|
|
return ::mlir::failure();
|
|
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 {
|
|
break;
|
|
}
|
|
}
|
|
if (parser.parseArrow())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
::mlir::omp::PointerLikeType type;
|
|
if (parser.parseCustomTypeWithFallback(type))
|
|
return ::mlir::failure();
|
|
omp_ptrRawType = 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<int32_t>({1, static_cast<int32_t>(var_ptr_ptrOperands.size()), static_cast<int32_t>(membersOperands.size()), static_cast<int32_t>(boundsOperands.size())}), result.getOrAddProperties<MapInfoOp::Properties>().operandSegmentSizes.begin());
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::omp::MapBoundsType>();
|
|
result.addTypes(omp_ptrTypes);
|
|
if (parser.resolveOperands(var_ptrOperands, var_ptrTypes, var_ptrOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!var_ptr_ptrOperands.empty()) {
|
|
if (parser.resolveOperands(var_ptr_ptrOperands, var_ptr_ptrTypes, var_ptr_ptrOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(membersOperands, membersTypes, membersOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MapInfoOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ' << "var_ptr";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getVarPtr();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
{
|
|
auto type = getVarPtr().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::omp::PointerLikeType>(type))
|
|
_odsPrinter.printStrippedAttrOrType(validType);
|
|
else
|
|
_odsPrinter << type;
|
|
}
|
|
_odsPrinter << ",";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printAttributeWithoutType(getVarPtrTypeAttr());
|
|
_odsPrinter << ")";
|
|
_odsPrinter << ' ' << "map_clauses";
|
|
_odsPrinter << "(";
|
|
printMapClause(_odsPrinter, *this, getMapTypeAttr());
|
|
_odsPrinter << ")";
|
|
_odsPrinter << ' ' << "capture";
|
|
_odsPrinter << "(";
|
|
printCaptureType(_odsPrinter, *this, getMapCaptureTypeAttr());
|
|
_odsPrinter << ")";
|
|
if (false || getVarPtrPtr() || (getVarPtrPtrTypeAttr())) {
|
|
_odsPrinter << ' ' << "var_ptr_ptr";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getVarPtrPtr())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>());
|
|
_odsPrinter << ",";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printAttributeWithoutType(getVarPtrPtrTypeAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getMapperIdAttr())) {
|
|
_odsPrinter << ' ' << "mapper";
|
|
_odsPrinter << "(";
|
|
_odsPrinter.printAttributeWithoutType(getMapperIdAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getMembers().size() || (getMembersIndexAttr())) {
|
|
_odsPrinter << ' ' << "members";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getMembers();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
printMembersIndex(_odsPrinter, *this, getMembersIndexAttr());
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getMembers().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getBounds().size()) {
|
|
_odsPrinter << ' ' << "bounds";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getBounds();
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ' << "->";
|
|
_odsPrinter << ' ';
|
|
{
|
|
auto type = getOmpPtr().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::omp::PointerLikeType>(type))
|
|
_odsPrinter.printStrippedAttrOrType(validType);
|
|
else
|
|
_odsPrinter << type;
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("var_ptr_type");
|
|
elidedAttrs.push_back("map_type");
|
|
elidedAttrs.push_back("map_capture_type");
|
|
elidedAttrs.push_back("var_ptr_ptr_type");
|
|
elidedAttrs.push_back("mapper_id");
|
|
elidedAttrs.push_back("members_index");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getPartialMapAttr();
|
|
if(attr && (attr == odsBuilder.getBoolAttr(false)))
|
|
elidedAttrs.push_back("partial_map");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::MapInfoOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::MapInfoOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::MaskedOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
MaskedOpGenericAdaptorBase::MaskedOpGenericAdaptorBase(MaskedOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> MaskedOpGenericAdaptorBase::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
|
|
MaskedOpAdaptor::MaskedOpAdaptor(MaskedOp op) : MaskedOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult MaskedOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> MaskedOp::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 MaskedOp::getFilteredThreadIdMutable() {
|
|
auto range = getODSOperandIndexAndLength(0);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
|
|
return mutableRange;
|
|
}
|
|
|
|
::llvm::LogicalResult MaskedOp::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 MaskedOp::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 MaskedOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> MaskedOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void MaskedOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void MaskedOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult MaskedOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
MaskedOp MaskedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const MaskedOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<MaskedOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaskedOp MaskedOp::create(::mlir::ImplicitLocOpBuilder &builder, const MaskedOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void MaskedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value filtered_thread_id) {
|
|
if (filtered_thread_id)
|
|
odsState.addOperands(filtered_thread_id);
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
MaskedOp MaskedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value filtered_thread_id) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(filtered_thread_id)>(filtered_thread_id));
|
|
auto __res__ = ::llvm::dyn_cast<MaskedOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaskedOp MaskedOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value filtered_thread_id) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(filtered_thread_id)>(filtered_thread_id));
|
|
}
|
|
|
|
void MaskedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value filtered_thread_id) {
|
|
if (filtered_thread_id)
|
|
odsState.addOperands(filtered_thread_id);
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MaskedOp MaskedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value filtered_thread_id) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(filtered_thread_id)>(filtered_thread_id));
|
|
auto __res__ = ::llvm::dyn_cast<MaskedOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaskedOp MaskedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value filtered_thread_id) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(filtered_thread_id)>(filtered_thread_id));
|
|
}
|
|
|
|
void MaskedOp::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);
|
|
}
|
|
|
|
MaskedOp MaskedOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<MaskedOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaskedOp MaskedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void MaskedOp::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&>(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);
|
|
}
|
|
|
|
MaskedOp MaskedOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<MaskedOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaskedOp MaskedOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult MaskedOp::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_OpenMPOps2(*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_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MaskedOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult MaskedOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> filtered_thread_idOperands;
|
|
::llvm::SMLoc filtered_thread_idOperandsLoc;
|
|
(void)filtered_thread_idOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> filtered_thread_idTypes;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
bool filterClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("filter"))) {
|
|
|
|
if (filterClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`filter` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
filterClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
filtered_thread_idOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
filtered_thread_idOperands.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();
|
|
filtered_thread_idTypes.push_back(optionalType);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
|
|
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));
|
|
if (!filtered_thread_idOperands.empty()) {
|
|
if (parser.resolveOperands(filtered_thread_idOperands, filtered_thread_idTypes, filtered_thread_idOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MaskedOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getFilteredThreadId()) {
|
|
_odsPrinter << ' ' << "filter";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getFilteredThreadId())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << (getFilteredThreadId() ? ::llvm::ArrayRef<::mlir::Type>(getFilteredThreadId().getType()) : ::llvm::ArrayRef<::mlir::Type>());
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getRegion());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::MaskedOp)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::MasterOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
MasterOpGenericAdaptorBase::MasterOpGenericAdaptorBase(MasterOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
MasterOpAdaptor::MasterOpAdaptor(MasterOp op) : MasterOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult MasterOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MasterOp::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 MasterOp::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 MasterOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> MasterOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void MasterOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void MasterOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult MasterOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MasterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) {
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
MasterOp MasterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__);
|
|
auto __res__ = ::llvm::dyn_cast<MasterOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MasterOp MasterOp::create(::mlir::ImplicitLocOpBuilder &builder) {
|
|
return create(builder, builder.getLoc());
|
|
}
|
|
|
|
void MasterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) {
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MasterOp MasterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes));
|
|
auto __res__ = ::llvm::dyn_cast<MasterOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MasterOp MasterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes));
|
|
}
|
|
|
|
void MasterOp::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);
|
|
}
|
|
|
|
MasterOp MasterOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<MasterOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MasterOp MasterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void MasterOp::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&>(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);
|
|
}
|
|
|
|
MasterOp MasterOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<MasterOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MasterOp MasterOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult MasterOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MasterOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult MasterOp::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 MasterOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getRegion());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::MasterOp)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::NewCliOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
NewCliOpGenericAdaptorBase::NewCliOpGenericAdaptorBase(NewCliOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
NewCliOpAdaptor::NewCliOpAdaptor(NewCliOp op) : NewCliOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult NewCliOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult NewCliOp::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 NewCliOp::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 NewCliOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> NewCliOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void NewCliOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void NewCliOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult NewCliOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
NewCliOp NewCliOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__);
|
|
auto __res__ = ::llvm::dyn_cast<NewCliOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
NewCliOp NewCliOp::create(::mlir::ImplicitLocOpBuilder &builder) {
|
|
return create(builder, builder.getLoc());
|
|
}
|
|
|
|
void NewCliOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result) {
|
|
odsState.addTypes(result);
|
|
}
|
|
|
|
NewCliOp NewCliOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(result)>(result));
|
|
auto __res__ = ::llvm::dyn_cast<NewCliOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
NewCliOp NewCliOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(result)>(result));
|
|
}
|
|
|
|
void NewCliOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) {
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
NewCliOp NewCliOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes));
|
|
auto __res__ = ::llvm::dyn_cast<NewCliOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
NewCliOp NewCliOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes));
|
|
}
|
|
|
|
void NewCliOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 0u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
NewCliOp NewCliOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<NewCliOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
NewCliOp NewCliOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void NewCliOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
NewCliOp NewCliOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<NewCliOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
NewCliOp NewCliOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult NewCliOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSResults(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps9(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult NewCliOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult NewCliOp::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();
|
|
}
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::omp::CanonicalLoopInfoType>();
|
|
result.addTypes(odsBuildableType0);
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void NewCliOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::NewCliOp)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::OrderedOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
OrderedOpGenericAdaptorBase::OrderedOpGenericAdaptorBase(OrderedOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> OrderedOpGenericAdaptorBase::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::omp::ClauseDepend> OrderedOpGenericAdaptorBase::getDoacrossDependType() {
|
|
auto attr = getDoacrossDependTypeAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseDepend>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<uint64_t> OrderedOpGenericAdaptorBase::getDoacrossNumLoops() {
|
|
auto attr = getDoacrossNumLoopsAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
OrderedOpAdaptor::OrderedOpAdaptor(OrderedOp op) : OrderedOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult OrderedOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_doacross_depend_type = getProperties().doacross_depend_type; (void)tblgen_doacross_depend_type;
|
|
auto tblgen_doacross_num_loops = getProperties().doacross_num_loops; (void)tblgen_doacross_num_loops;
|
|
|
|
if (tblgen_doacross_depend_type && !((::llvm::isa<::mlir::omp::ClauseDependAttr>(tblgen_doacross_depend_type))))
|
|
return emitError(loc, "'omp.ordered' op attribute 'doacross_depend_type' failed to satisfy constraint: depend clause");
|
|
|
|
if (tblgen_doacross_num_loops && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_doacross_num_loops))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_doacross_num_loops).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_doacross_num_loops).getInt() >= 0))))
|
|
return emitError(loc, "'omp.ordered' op attribute 'doacross_num_loops' failed to satisfy constraint: 64-bit signless integer attribute whose minimum value is 0");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> OrderedOp::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 OrderedOp::getDoacrossDependVarsMutable() {
|
|
auto range = getODSOperandIndexAndLength(0);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
|
|
return mutableRange;
|
|
}
|
|
|
|
::llvm::LogicalResult OrderedOp::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.doacross_depend_type;
|
|
auto attr = dict.get("doacross_depend_type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `doacross_depend_type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.doacross_num_loops;
|
|
auto attr = dict.get("doacross_num_loops");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `doacross_num_loops` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute OrderedOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.doacross_depend_type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("doacross_depend_type",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.doacross_num_loops;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("doacross_num_loops",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code OrderedOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.doacross_depend_type.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.doacross_num_loops.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> OrderedOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "doacross_depend_type")
|
|
return prop.doacross_depend_type;
|
|
|
|
if (name == "doacross_num_loops")
|
|
return prop.doacross_num_loops;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void OrderedOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "doacross_depend_type") {
|
|
prop.doacross_depend_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.doacross_depend_type)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "doacross_num_loops") {
|
|
prop.doacross_num_loops = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.doacross_num_loops)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void OrderedOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.doacross_depend_type) attrs.append("doacross_depend_type", prop.doacross_depend_type);
|
|
|
|
if (prop.doacross_num_loops) attrs.append("doacross_num_loops", prop.doacross_num_loops);
|
|
}
|
|
|
|
::llvm::LogicalResult OrderedOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDoacrossDependTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps25(attr, "doacross_depend_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDoacrossNumLoopsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps26(attr, "doacross_num_loops", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult OrderedOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.doacross_depend_type)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.doacross_num_loops)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void OrderedOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.doacross_depend_type);
|
|
|
|
writer.writeOptionalAttribute(prop.doacross_num_loops);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseDepend> OrderedOp::getDoacrossDependType() {
|
|
auto attr = getDoacrossDependTypeAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseDepend>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<uint64_t> OrderedOp::getDoacrossNumLoops() {
|
|
auto attr = getDoacrossNumLoopsAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
void OrderedOp::setDoacrossDependType(::std::optional<::mlir::omp::ClauseDepend> attrValue) {
|
|
auto &odsProp = getProperties().doacross_depend_type;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ClauseDependAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void OrderedOp::setDoacrossNumLoops(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().doacross_num_loops;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
OrderedOp OrderedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const OrderedOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<OrderedOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
OrderedOp OrderedOp::create(::mlir::ImplicitLocOpBuilder &builder, const OrderedOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void OrderedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::omp::ClauseDependAttr doacross_depend_type, /*optional*/::mlir::IntegerAttr doacross_num_loops, ::mlir::ValueRange doacross_depend_vars) {
|
|
odsState.addOperands(doacross_depend_vars);
|
|
if (doacross_depend_type) {
|
|
odsState.getOrAddProperties<Properties>().doacross_depend_type = doacross_depend_type;
|
|
}
|
|
if (doacross_num_loops) {
|
|
odsState.getOrAddProperties<Properties>().doacross_num_loops = doacross_num_loops;
|
|
}
|
|
}
|
|
|
|
OrderedOp OrderedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::omp::ClauseDependAttr doacross_depend_type, /*optional*/::mlir::IntegerAttr doacross_num_loops, ::mlir::ValueRange doacross_depend_vars) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(doacross_depend_type)>(doacross_depend_type), std::forward<decltype(doacross_num_loops)>(doacross_num_loops), std::forward<decltype(doacross_depend_vars)>(doacross_depend_vars));
|
|
auto __res__ = ::llvm::dyn_cast<OrderedOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
OrderedOp OrderedOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::omp::ClauseDependAttr doacross_depend_type, /*optional*/::mlir::IntegerAttr doacross_num_loops, ::mlir::ValueRange doacross_depend_vars) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(doacross_depend_type)>(doacross_depend_type), std::forward<decltype(doacross_num_loops)>(doacross_num_loops), std::forward<decltype(doacross_depend_vars)>(doacross_depend_vars));
|
|
}
|
|
|
|
void OrderedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::omp::ClauseDependAttr doacross_depend_type, /*optional*/::mlir::IntegerAttr doacross_num_loops, ::mlir::ValueRange doacross_depend_vars) {
|
|
odsState.addOperands(doacross_depend_vars);
|
|
if (doacross_depend_type) {
|
|
odsState.getOrAddProperties<Properties>().doacross_depend_type = doacross_depend_type;
|
|
}
|
|
if (doacross_num_loops) {
|
|
odsState.getOrAddProperties<Properties>().doacross_num_loops = doacross_num_loops;
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
OrderedOp OrderedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::omp::ClauseDependAttr doacross_depend_type, /*optional*/::mlir::IntegerAttr doacross_num_loops, ::mlir::ValueRange doacross_depend_vars) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(doacross_depend_type)>(doacross_depend_type), std::forward<decltype(doacross_num_loops)>(doacross_num_loops), std::forward<decltype(doacross_depend_vars)>(doacross_depend_vars));
|
|
auto __res__ = ::llvm::dyn_cast<OrderedOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
OrderedOp OrderedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::omp::ClauseDependAttr doacross_depend_type, /*optional*/::mlir::IntegerAttr doacross_num_loops, ::mlir::ValueRange doacross_depend_vars) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(doacross_depend_type)>(doacross_depend_type), std::forward<decltype(doacross_num_loops)>(doacross_num_loops), std::forward<decltype(doacross_depend_vars)>(doacross_depend_vars));
|
|
}
|
|
|
|
void OrderedOp::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<OrderedOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
OrderedOp OrderedOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<OrderedOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
OrderedOp OrderedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void OrderedOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
OrderedOp OrderedOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<OrderedOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
OrderedOp OrderedOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult OrderedOp::verifyInvariantsImpl() {
|
|
auto tblgen_doacross_depend_type = getProperties().doacross_depend_type; (void)tblgen_doacross_depend_type;
|
|
auto tblgen_doacross_num_loops = getProperties().doacross_num_loops; (void)tblgen_doacross_num_loops;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps25(*this, tblgen_doacross_depend_type, "doacross_depend_type")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps26(*this, tblgen_doacross_num_loops, "doacross_num_loops")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult OrderedOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult OrderedOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::omp::ClauseDependAttr doacross_depend_typeAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> doacross_depend_varsOperands;
|
|
::llvm::SMLoc doacross_depend_varsOperandsLoc;
|
|
(void)doacross_depend_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> doacross_depend_varsTypes;
|
|
if (::mlir::succeeded(parser.parseOptionalKeyword("depend_type"))) {
|
|
|
|
if (parser.parseCustomAttributeWithFallback(doacross_depend_typeAttr, ::mlir::Type{})) {
|
|
return ::mlir::failure();
|
|
}
|
|
if (doacross_depend_typeAttr) result.getOrAddProperties<OrderedOp::Properties>().doacross_depend_type = doacross_depend_typeAttr;
|
|
}
|
|
if (::mlir::succeeded(parser.parseOptionalKeyword("depend_vec"))) {
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
doacross_depend_varsOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(doacross_depend_varsOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(doacross_depend_varsTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
}
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
|
|
return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
|
|
})))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(doacross_depend_varsOperands, doacross_depend_varsTypes, doacross_depend_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void OrderedOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (getDoacrossDependTypeAttr()) {
|
|
_odsPrinter << ' ' << "depend_type";
|
|
_odsPrinter.printStrippedAttrOrType(getDoacrossDependTypeAttr());
|
|
}
|
|
if (!getDoacrossDependVars().empty()) {
|
|
_odsPrinter << ' ' << "depend_vec";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getDoacrossDependVars();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getDoacrossDependVars().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("doacross_depend_type");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::OrderedOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::OrderedOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::OrderedRegionOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
OrderedRegionOpGenericAdaptorBase::OrderedRegionOpGenericAdaptorBase(OrderedRegionOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::UnitAttr OrderedRegionOpGenericAdaptorBase::getParLevelSimdAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().par_level_simd);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool OrderedRegionOpGenericAdaptorBase::getParLevelSimd() {
|
|
auto attr = getParLevelSimdAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
OrderedRegionOpAdaptor::OrderedRegionOpAdaptor(OrderedRegionOp op) : OrderedRegionOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult OrderedRegionOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_par_level_simd = getProperties().par_level_simd; (void)tblgen_par_level_simd;
|
|
|
|
if (tblgen_par_level_simd && !((::llvm::isa<::mlir::UnitAttr>(tblgen_par_level_simd))))
|
|
return emitError(loc, "'omp.ordered.region' op attribute 'par_level_simd' failed to satisfy constraint: unit attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult OrderedRegionOp::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_level_simd;
|
|
auto attr = dict.get("par_level_simd");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `par_level_simd` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute OrderedRegionOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.par_level_simd;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("par_level_simd",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code OrderedRegionOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.par_level_simd.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> OrderedRegionOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "par_level_simd")
|
|
return prop.par_level_simd;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void OrderedRegionOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "par_level_simd") {
|
|
prop.par_level_simd = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.par_level_simd)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void OrderedRegionOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.par_level_simd) attrs.append("par_level_simd", prop.par_level_simd);
|
|
}
|
|
|
|
::llvm::LogicalResult OrderedRegionOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getParLevelSimdAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "par_level_simd", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult OrderedRegionOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.par_level_simd)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void OrderedRegionOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.par_level_simd);
|
|
}
|
|
|
|
bool OrderedRegionOp::getParLevelSimd() {
|
|
auto attr = getParLevelSimdAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
void OrderedRegionOp::setParLevelSimd(bool attrValue) {
|
|
auto &odsProp = getProperties().par_level_simd;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
OrderedRegionOp OrderedRegionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const OrderedRegionOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<OrderedRegionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
OrderedRegionOp OrderedRegionOp::create(::mlir::ImplicitLocOpBuilder &builder, const OrderedRegionOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void OrderedRegionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::UnitAttr par_level_simd) {
|
|
if (par_level_simd) {
|
|
odsState.getOrAddProperties<Properties>().par_level_simd = par_level_simd;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
OrderedRegionOp OrderedRegionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::UnitAttr par_level_simd) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(par_level_simd)>(par_level_simd));
|
|
auto __res__ = ::llvm::dyn_cast<OrderedRegionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
OrderedRegionOp OrderedRegionOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::UnitAttr par_level_simd) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(par_level_simd)>(par_level_simd));
|
|
}
|
|
|
|
void OrderedRegionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr par_level_simd) {
|
|
if (par_level_simd) {
|
|
odsState.getOrAddProperties<Properties>().par_level_simd = par_level_simd;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
OrderedRegionOp OrderedRegionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr par_level_simd) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(par_level_simd)>(par_level_simd));
|
|
auto __res__ = ::llvm::dyn_cast<OrderedRegionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
OrderedRegionOp OrderedRegionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr par_level_simd) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(par_level_simd)>(par_level_simd));
|
|
}
|
|
|
|
void OrderedRegionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/bool par_level_simd) {
|
|
if (par_level_simd) {
|
|
odsState.getOrAddProperties<Properties>().par_level_simd = ((par_level_simd) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
OrderedRegionOp OrderedRegionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/bool par_level_simd) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(par_level_simd)>(par_level_simd));
|
|
auto __res__ = ::llvm::dyn_cast<OrderedRegionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
OrderedRegionOp OrderedRegionOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/bool par_level_simd) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(par_level_simd)>(par_level_simd));
|
|
}
|
|
|
|
void OrderedRegionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/bool par_level_simd) {
|
|
if (par_level_simd) {
|
|
odsState.getOrAddProperties<Properties>().par_level_simd = ((par_level_simd) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
OrderedRegionOp OrderedRegionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/bool par_level_simd) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(par_level_simd)>(par_level_simd));
|
|
auto __res__ = ::llvm::dyn_cast<OrderedRegionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
OrderedRegionOp OrderedRegionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/bool par_level_simd) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(par_level_simd)>(par_level_simd));
|
|
}
|
|
|
|
void OrderedRegionOp::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<OrderedRegionOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
OrderedRegionOp OrderedRegionOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<OrderedRegionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
OrderedRegionOp OrderedRegionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void OrderedRegionOp::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&>(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);
|
|
}
|
|
|
|
OrderedRegionOp OrderedRegionOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<OrderedRegionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
OrderedRegionOp OrderedRegionOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult OrderedRegionOp::verifyInvariantsImpl() {
|
|
auto tblgen_par_level_simd = getProperties().par_level_simd; (void)tblgen_par_level_simd;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_par_level_simd, "par_level_simd")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult OrderedRegionOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult OrderedRegionOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
bool par_level_simdClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("par_level_simd"))) {
|
|
|
|
if (par_level_simdClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`par_level_simd` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
par_level_simdClause = true;
|
|
result.getOrAddProperties<OrderedRegionOp::Properties>().par_level_simd = parser.getBuilder().getUnitAttr(); } else {
|
|
break;
|
|
}
|
|
}
|
|
|
|
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 OrderedRegionOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || ((getParLevelSimdAttr() && getParLevelSimdAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "par_level_simd";
|
|
}
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getRegion());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("par_level_simd");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getParLevelSimdAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("par_level_simd");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::OrderedRegionOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::OrderedRegionOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::ParallelOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ParallelOpGenericAdaptorBase::ParallelOpGenericAdaptorBase(ParallelOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> ParallelOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> 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::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr ParallelOpGenericAdaptorBase::getPrivateNeedsBarrierAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().private_needs_barrier);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool ParallelOpGenericAdaptorBase::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseProcBindKind> ParallelOpGenericAdaptorBase::getProcBindKind() {
|
|
auto attr = getProcBindKindAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseProcBindKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ReductionModifier> ParallelOpGenericAdaptorBase::getReductionMod() {
|
|
auto attr = getReductionModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ReductionModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> ParallelOpGenericAdaptorBase::getReductionByref() {
|
|
auto attr = getReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > ParallelOpGenericAdaptorBase::getReductionSyms() {
|
|
auto attr = getReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ParallelOpAdaptor::ParallelOpAdaptor(ParallelOp op) : ParallelOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ParallelOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_proc_bind_kind = getProperties().proc_bind_kind; (void)tblgen_proc_bind_kind;
|
|
auto tblgen_reduction_byref = getProperties().reduction_byref; (void)tblgen_reduction_byref;
|
|
auto tblgen_reduction_mod = getProperties().reduction_mod; (void)tblgen_reduction_mod;
|
|
auto tblgen_reduction_syms = getProperties().reduction_syms; (void)tblgen_reduction_syms;
|
|
|
|
if (tblgen_private_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_private_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_private_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.parallel' op attribute 'private_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_private_needs_barrier && !((::llvm::isa<::mlir::UnitAttr>(tblgen_private_needs_barrier))))
|
|
return emitError(loc, "'omp.parallel' op attribute 'private_needs_barrier' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_proc_bind_kind && !((::llvm::isa<::mlir::omp::ClauseProcBindKindAttr>(tblgen_proc_bind_kind))))
|
|
return emitError(loc, "'omp.parallel' op attribute 'proc_bind_kind' failed to satisfy constraint: ProcBindKind Clause");
|
|
|
|
if (tblgen_reduction_mod && !((::llvm::isa<::mlir::omp::ReductionModifierAttr>(tblgen_reduction_mod))))
|
|
return emitError(loc, "'omp.parallel' op attribute 'reduction_mod' failed to satisfy constraint: reduction modifier");
|
|
|
|
if (tblgen_reduction_byref && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(tblgen_reduction_byref))))
|
|
return emitError(loc, "'omp.parallel' op attribute 'reduction_byref' failed to satisfy constraint: i1 dense array attribute");
|
|
|
|
if (tblgen_reduction_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_reduction_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_reduction_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.parallel' op attribute 'reduction_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> ParallelOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange ParallelOp::getAllocateVarsMutable() {
|
|
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::getAllocatorVarsMutable() {
|
|
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::getIfExprMutable() {
|
|
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::getNumThreadsVarsMutable() {
|
|
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::getPrivateVarsMutable() {
|
|
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::getReductionVarsMutable() {
|
|
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;
|
|
}
|
|
|
|
::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.private_needs_barrier;
|
|
auto attr = dict.get("private_needs_barrier");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_needs_barrier` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_syms;
|
|
auto attr = dict.get("private_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_syms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.proc_bind_kind;
|
|
auto attr = dict.get("proc_bind_kind");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `proc_bind_kind` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_byref;
|
|
auto attr = dict.get("reduction_byref");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_byref` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_mod;
|
|
auto attr = dict.get("reduction_mod");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_mod` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_syms;
|
|
auto attr = dict.get("reduction_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_syms` 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.private_needs_barrier;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_needs_barrier",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_syms",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.proc_bind_kind;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("proc_bind_kind",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_byref;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_byref",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_mod;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_mod",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_syms",
|
|
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.private_needs_barrier.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_syms.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.proc_bind_kind.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_byref.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_mod.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_syms.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ParallelOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "private_needs_barrier")
|
|
return prop.private_needs_barrier;
|
|
|
|
if (name == "private_syms")
|
|
return prop.private_syms;
|
|
|
|
if (name == "proc_bind_kind")
|
|
return prop.proc_bind_kind;
|
|
|
|
if (name == "reduction_byref")
|
|
return prop.reduction_byref;
|
|
|
|
if (name == "reduction_mod")
|
|
return prop.reduction_mod;
|
|
|
|
if (name == "reduction_syms")
|
|
return prop.reduction_syms;
|
|
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 == "private_needs_barrier") {
|
|
prop.private_needs_barrier = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_needs_barrier)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_syms") {
|
|
prop.private_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_syms)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "proc_bind_kind") {
|
|
prop.proc_bind_kind = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.proc_bind_kind)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_byref") {
|
|
prop.reduction_byref = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_byref)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_mod") {
|
|
prop.reduction_mod = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_mod)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_syms") {
|
|
prop.reduction_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_syms)>>(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.private_needs_barrier) attrs.append("private_needs_barrier", prop.private_needs_barrier);
|
|
|
|
if (prop.private_syms) attrs.append("private_syms", prop.private_syms);
|
|
|
|
if (prop.proc_bind_kind) attrs.append("proc_bind_kind", prop.proc_bind_kind);
|
|
|
|
if (prop.reduction_byref) attrs.append("reduction_byref", prop.reduction_byref);
|
|
|
|
if (prop.reduction_mod) attrs.append("reduction_mod", prop.reduction_mod);
|
|
|
|
if (prop.reduction_syms) attrs.append("reduction_syms", prop.reduction_syms);
|
|
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(getPrivateNeedsBarrierAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "private_needs_barrier", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "private_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getProcBindKindAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps27(attr, "proc_bind_kind", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionByrefAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(attr, "reduction_byref", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionModAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps19(attr, "reduction_mod", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "reduction_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ParallelOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_needs_barrier)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_syms)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.proc_bind_kind)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_byref)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_mod)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_syms)))
|
|
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;
|
|
|
|
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
|
|
}
|
|
|
|
writer.writeOptionalAttribute(prop.private_needs_barrier);
|
|
|
|
writer.writeOptionalAttribute(prop.private_syms);
|
|
|
|
writer.writeOptionalAttribute(prop.proc_bind_kind);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_byref);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_mod);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_syms);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > ParallelOp::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool ParallelOp::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseProcBindKind> ParallelOp::getProcBindKind() {
|
|
auto attr = getProcBindKindAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseProcBindKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ReductionModifier> ParallelOp::getReductionMod() {
|
|
auto attr = getReductionModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ReductionModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> ParallelOp::getReductionByref() {
|
|
auto attr = getReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > ParallelOp::getReductionSyms() {
|
|
auto attr = getReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
void ParallelOp::setPrivateNeedsBarrier(bool attrValue) {
|
|
auto &odsProp = getProperties().private_needs_barrier;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void ParallelOp::setProcBindKind(::std::optional<::mlir::omp::ClauseProcBindKind> attrValue) {
|
|
auto &odsProp = getProperties().proc_bind_kind;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ClauseProcBindKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void ParallelOp::setReductionMod(::std::optional<::mlir::omp::ReductionModifier> attrValue) {
|
|
auto &odsProp = getProperties().reduction_mod;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ReductionModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void ParallelOp::setReductionByref(::std::optional<::llvm::ArrayRef<bool>> attrValue) {
|
|
auto &odsProp = getProperties().reduction_byref;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getDenseBoolArrayAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
ParallelOp ParallelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ArrayRef<NamedAttribute> attributes) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<ParallelOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ParallelOp ParallelOp::create(::mlir::ImplicitLocOpBuilder &builder, ArrayRef<NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
ParallelOp ParallelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const ParallelOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<ParallelOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ParallelOp ParallelOp::create(::mlir::ImplicitLocOpBuilder &builder, const ParallelOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void ParallelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange num_threads_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ClauseProcBindKindAttr proc_bind_kind, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(num_threads_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), (if_expr ? 1 : 0), static_cast<int32_t>(num_threads_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (proc_bind_kind) {
|
|
odsState.getOrAddProperties<Properties>().proc_bind_kind = proc_bind_kind;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
ParallelOp ParallelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange num_threads_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ClauseProcBindKindAttr proc_bind_kind, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(num_threads_vars)>(num_threads_vars), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(proc_bind_kind)>(proc_bind_kind), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<ParallelOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ParallelOp ParallelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange num_threads_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ClauseProcBindKindAttr proc_bind_kind, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(num_threads_vars)>(num_threads_vars), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(proc_bind_kind)>(proc_bind_kind), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
}
|
|
|
|
void ParallelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange num_threads_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ClauseProcBindKindAttr proc_bind_kind, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(num_threads_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), (if_expr ? 1 : 0), static_cast<int32_t>(num_threads_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (proc_bind_kind) {
|
|
odsState.getOrAddProperties<Properties>().proc_bind_kind = proc_bind_kind;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(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 allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange num_threads_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ClauseProcBindKindAttr proc_bind_kind, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(num_threads_vars)>(num_threads_vars), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(proc_bind_kind)>(proc_bind_kind), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<ParallelOp>(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 allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange num_threads_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ClauseProcBindKindAttr proc_bind_kind, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(num_threads_vars)>(num_threads_vars), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(proc_bind_kind)>(proc_bind_kind), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
}
|
|
|
|
void ParallelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange num_threads_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ClauseProcBindKindAttr proc_bind_kind, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(num_threads_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), (if_expr ? 1 : 0), static_cast<int32_t>(num_threads_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (proc_bind_kind) {
|
|
odsState.getOrAddProperties<Properties>().proc_bind_kind = proc_bind_kind;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
ParallelOp ParallelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange num_threads_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ClauseProcBindKindAttr proc_bind_kind, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(num_threads_vars)>(num_threads_vars), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(proc_bind_kind)>(proc_bind_kind), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<ParallelOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ParallelOp ParallelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange num_threads_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ClauseProcBindKindAttr proc_bind_kind, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(num_threads_vars)>(num_threads_vars), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(proc_bind_kind)>(proc_bind_kind), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
}
|
|
|
|
void ParallelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange num_threads_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ClauseProcBindKindAttr proc_bind_kind, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(num_threads_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), (if_expr ? 1 : 0), static_cast<int32_t>(num_threads_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (proc_bind_kind) {
|
|
odsState.getOrAddProperties<Properties>().proc_bind_kind = proc_bind_kind;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(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 allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange num_threads_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ClauseProcBindKindAttr proc_bind_kind, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(num_threads_vars)>(num_threads_vars), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(proc_bind_kind)>(proc_bind_kind), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<ParallelOp>(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 allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange num_threads_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ClauseProcBindKindAttr proc_bind_kind, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(num_threads_vars)>(num_threads_vars), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(proc_bind_kind)>(proc_bind_kind), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
}
|
|
|
|
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<ParallelOp::Properties>();
|
|
::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<ParallelOp>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(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&>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<ParallelOp>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult ParallelOp::verifyInvariantsImpl() {
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_proc_bind_kind = getProperties().proc_bind_kind; (void)tblgen_proc_bind_kind;
|
|
auto tblgen_reduction_byref = getProperties().reduction_byref; (void)tblgen_reduction_byref;
|
|
auto tblgen_reduction_mod = getProperties().reduction_mod; (void)tblgen_reduction_mod;
|
|
auto tblgen_reduction_syms = getProperties().reduction_syms; (void)tblgen_reduction_syms;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_private_syms, "private_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_private_needs_barrier, "private_needs_barrier")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps27(*this, tblgen_proc_bind_kind, "proc_bind_kind")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps19(*this, tblgen_reduction_mod, "reduction_mod")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(*this, tblgen_reduction_byref, "reduction_byref")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_reduction_syms, "reduction_syms")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*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_OpenMPOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps14(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup4 = getODSOperands(4);
|
|
|
|
for (auto v : valueGroup4) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup5 = getODSOperands(5);
|
|
|
|
for (auto v : valueGroup5) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*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_OpenMPOps2(*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> allocate_varsOperands;
|
|
::llvm::SMLoc allocate_varsOperandsLoc;
|
|
(void)allocate_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocate_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocator_varsOperands;
|
|
::llvm::SMLoc allocator_varsOperandsLoc;
|
|
(void)allocator_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocator_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> if_exprOperands;
|
|
::llvm::SMLoc if_exprOperandsLoc;
|
|
(void)if_exprOperandsLoc;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> num_threads_varsOperands;
|
|
::llvm::SMLoc num_threads_varsOperandsLoc;
|
|
(void)num_threads_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> num_threads_varsTypes;
|
|
::mlir::omp::ClauseProcBindKindAttr proc_bind_kindAttr;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> private_varsOperands;
|
|
::llvm::SMLoc private_varsOperandsLoc;
|
|
(void)private_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> private_varsTypes;
|
|
::mlir::ArrayAttr private_symsAttr;
|
|
::mlir::UnitAttr private_needs_barrierAttr;
|
|
::mlir::omp::ReductionModifierAttr reduction_modAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> reduction_varsOperands;
|
|
::llvm::SMLoc reduction_varsOperandsLoc;
|
|
(void)reduction_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> reduction_varsTypes;
|
|
::mlir::DenseBoolArrayAttr reduction_byrefAttr;
|
|
::mlir::ArrayAttr reduction_symsAttr;
|
|
bool allocateClause = false;
|
|
bool ifClause = false;
|
|
bool num_threadsClause = false;
|
|
bool proc_bindClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("allocate"))) {
|
|
|
|
if (allocateClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`allocate` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
allocateClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
allocate_varsOperandsLoc = parser.getCurrentLocation();
|
|
allocator_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseAllocateAndAllocator(parser, allocate_varsOperands, allocate_varsTypes, allocator_varsOperands, allocator_varsTypes);
|
|
if (odsResult) return ::mlir::failure();
|
|
}
|
|
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();
|
|
|
|
{
|
|
if_exprOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
if_exprOperands.push_back(operand);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("num_threads"))) {
|
|
|
|
if (num_threadsClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`num_threads` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
num_threadsClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
num_threads_varsOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(num_threads_varsOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(num_threads_varsTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("proc_bind"))) {
|
|
|
|
if (proc_bindClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`proc_bind` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
proc_bindClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseClauseAttr(parser, proc_bind_kindAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (proc_bind_kindAttr)
|
|
result.getOrAddProperties<ParallelOp::Properties>().proc_bind_kind = proc_bind_kindAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
{
|
|
private_varsOperandsLoc = parser.getCurrentLocation();
|
|
reduction_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parsePrivateReductionRegion(parser, *regionRegion, private_varsOperands, private_varsTypes, private_symsAttr, private_needs_barrierAttr, reduction_modAttr, reduction_varsOperands, reduction_varsTypes, reduction_byrefAttr, reduction_symsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (private_symsAttr)
|
|
result.getOrAddProperties<ParallelOp::Properties>().private_syms = private_symsAttr;
|
|
if (private_needs_barrierAttr)
|
|
result.getOrAddProperties<ParallelOp::Properties>().private_needs_barrier = private_needs_barrierAttr;
|
|
if (reduction_modAttr)
|
|
result.getOrAddProperties<ParallelOp::Properties>().reduction_mod = reduction_modAttr;
|
|
if (reduction_byrefAttr)
|
|
result.getOrAddProperties<ParallelOp::Properties>().reduction_byref = reduction_byrefAttr;
|
|
if (reduction_symsAttr)
|
|
result.getOrAddProperties<ParallelOp::Properties>().reduction_syms = reduction_symsAttr;
|
|
}
|
|
{
|
|
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<int32_t>({static_cast<int32_t>(allocate_varsOperands.size()), static_cast<int32_t>(allocator_varsOperands.size()), static_cast<int32_t>(if_exprOperands.size()), static_cast<int32_t>(num_threads_varsOperands.size()), static_cast<int32_t>(private_varsOperands.size()), static_cast<int32_t>(reduction_varsOperands.size())}), result.getOrAddProperties<ParallelOp::Properties>().operandSegmentSizes.begin());
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1);
|
|
if (parser.resolveOperands(allocate_varsOperands, allocate_varsTypes, allocate_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(allocator_varsOperands, allocator_varsTypes, allocator_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!if_exprOperands.empty()) {
|
|
if (parser.resolveOperands(if_exprOperands, odsBuildableType0, if_exprOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(num_threads_varsOperands, num_threads_varsTypes, num_threads_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(private_varsOperands, private_varsTypes, private_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(reduction_varsOperands, reduction_varsTypes, reduction_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ParallelOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getAllocateVars().size() || getAllocatorVars().size()) {
|
|
_odsPrinter << ' ' << "allocate";
|
|
_odsPrinter << "(";
|
|
printAllocateAndAllocator(_odsPrinter, *this, getAllocateVars(), getAllocateVars().getTypes(), getAllocatorVars(), getAllocatorVars().getTypes());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getIfExpr()) {
|
|
_odsPrinter << ' ' << "if";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getIfExpr())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getNumThreadsVars().size()) {
|
|
_odsPrinter << ' ' << "num_threads";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getNumThreadsVars();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getNumThreadsVars().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getProcBindKindAttr())) {
|
|
_odsPrinter << ' ' << "proc_bind";
|
|
_odsPrinter << "(";
|
|
printClauseAttr(_odsPrinter, *this, getProcBindKindAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ';
|
|
printPrivateReductionRegion(_odsPrinter, *this, getRegion(), getPrivateVars(), getPrivateVars().getTypes(), getPrivateSymsAttr(), getPrivateNeedsBarrierAttr(), getReductionModAttr(), getReductionVars(), getReductionVars().getTypes(), getReductionByrefAttr(), getReductionSymsAttr());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("proc_bind_kind");
|
|
elidedAttrs.push_back("private_syms");
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
elidedAttrs.push_back("reduction_mod");
|
|
elidedAttrs.push_back("reduction_byref");
|
|
elidedAttrs.push_back("reduction_syms");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getPrivateNeedsBarrierAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::ParallelOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::ParallelOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::PrivateClauseOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
PrivateClauseOpGenericAdaptorBase::PrivateClauseOpGenericAdaptorBase(PrivateClauseOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::llvm::StringRef PrivateClauseOpGenericAdaptorBase::getSymName() {
|
|
auto attr = getSymNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::mlir::Type PrivateClauseOpGenericAdaptorBase::getType() {
|
|
auto attr = getTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::mlir::omp::DataSharingClauseType PrivateClauseOpGenericAdaptorBase::getDataSharingType() {
|
|
auto attr = getDataSharingTypeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
PrivateClauseOpAdaptor::PrivateClauseOpAdaptor(PrivateClauseOp op) : PrivateClauseOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult PrivateClauseOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_data_sharing_type = getProperties().data_sharing_type; (void)tblgen_data_sharing_type;
|
|
if (!tblgen_data_sharing_type) return emitError(loc, "'omp.private' op requires attribute 'data_sharing_type'");
|
|
auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
|
|
if (!tblgen_sym_name) return emitError(loc, "'omp.private' op requires attribute 'sym_name'");
|
|
auto tblgen_type = getProperties().type; (void)tblgen_type;
|
|
if (!tblgen_type) return emitError(loc, "'omp.private' op requires attribute 'type'");
|
|
|
|
if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name))))
|
|
return emitError(loc, "'omp.private' 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()))) && (!((::llvm::isa<::mlir::TokenType>(::llvm::cast<::mlir::TypeAttr>(tblgen_type).getValue()))))))
|
|
return emitError(loc, "'omp.private' op attribute 'type' failed to satisfy constraint: type attribute of any non-token type");
|
|
|
|
if (tblgen_data_sharing_type && !((::llvm::isa<::mlir::omp::DataSharingClauseTypeAttr>(tblgen_data_sharing_type))))
|
|
return emitError(loc, "'omp.private' op attribute 'data_sharing_type' failed to satisfy constraint: Type of a data-sharing clause");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult PrivateClauseOp::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.data_sharing_type;
|
|
auto attr = dict.get("data_sharing_type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `data_sharing_type` 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<std::remove_reference_t<decltype(propStorage)>>(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<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute PrivateClauseOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.data_sharing_type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("data_sharing_type",
|
|
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 PrivateClauseOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.data_sharing_type.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.sym_name.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.type.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> PrivateClauseOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "data_sharing_type")
|
|
return prop.data_sharing_type;
|
|
|
|
if (name == "sym_name")
|
|
return prop.sym_name;
|
|
|
|
if (name == "type")
|
|
return prop.type;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void PrivateClauseOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "data_sharing_type") {
|
|
prop.data_sharing_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.data_sharing_type)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "sym_name") {
|
|
prop.sym_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.sym_name)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "type") {
|
|
prop.type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.type)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void PrivateClauseOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.data_sharing_type) attrs.append("data_sharing_type", prop.data_sharing_type);
|
|
|
|
if (prop.sym_name) attrs.append("sym_name", prop.sym_name);
|
|
|
|
if (prop.type) attrs.append("type", prop.type);
|
|
}
|
|
|
|
::llvm::LogicalResult PrivateClauseOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDataSharingTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps29(attr, "data_sharing_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps8(attr, "sym_name", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps28(attr, "type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult PrivateClauseOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.data_sharing_type)))
|
|
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 PrivateClauseOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.data_sharing_type);
|
|
writer.writeAttribute(prop.sym_name);
|
|
writer.writeAttribute(prop.type);
|
|
}
|
|
|
|
::llvm::StringRef PrivateClauseOp::getSymName() {
|
|
auto attr = getSymNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::mlir::Type PrivateClauseOp::getType() {
|
|
auto attr = getTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::mlir::omp::DataSharingClauseType PrivateClauseOp::getDataSharingType() {
|
|
auto attr = getDataSharingTypeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void PrivateClauseOp::setSymName(::llvm::StringRef attrValue) {
|
|
getProperties().sym_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
|
|
}
|
|
|
|
void PrivateClauseOp::setType(::mlir::Type attrValue) {
|
|
getProperties().type = ::mlir::TypeAttr::get(attrValue);
|
|
}
|
|
|
|
void PrivateClauseOp::setDataSharingType(::mlir::omp::DataSharingClauseType attrValue) {
|
|
getProperties().data_sharing_type = ::mlir::omp::DataSharingClauseTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
PrivateClauseOp PrivateClauseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, TypeRange result, StringAttr sym_name, TypeAttr type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type));
|
|
auto __res__ = ::llvm::dyn_cast<PrivateClauseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
PrivateClauseOp PrivateClauseOp::create(::mlir::ImplicitLocOpBuilder &builder, TypeRange result, StringAttr sym_name, TypeAttr type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type));
|
|
}
|
|
|
|
void PrivateClauseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, ::mlir::omp::DataSharingClauseTypeAttr data_sharing_type) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = sym_name;
|
|
odsState.getOrAddProperties<Properties>().type = type;
|
|
odsState.getOrAddProperties<Properties>().data_sharing_type = data_sharing_type;
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
PrivateClauseOp PrivateClauseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, ::mlir::omp::DataSharingClauseTypeAttr data_sharing_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type), std::forward<decltype(data_sharing_type)>(data_sharing_type));
|
|
auto __res__ = ::llvm::dyn_cast<PrivateClauseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
PrivateClauseOp PrivateClauseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, ::mlir::omp::DataSharingClauseTypeAttr data_sharing_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type), std::forward<decltype(data_sharing_type)>(data_sharing_type));
|
|
}
|
|
|
|
void PrivateClauseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, ::mlir::omp::DataSharingClauseTypeAttr data_sharing_type) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = sym_name;
|
|
odsState.getOrAddProperties<Properties>().type = type;
|
|
odsState.getOrAddProperties<Properties>().data_sharing_type = data_sharing_type;
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
PrivateClauseOp PrivateClauseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, ::mlir::omp::DataSharingClauseTypeAttr data_sharing_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type), std::forward<decltype(data_sharing_type)>(data_sharing_type));
|
|
auto __res__ = ::llvm::dyn_cast<PrivateClauseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
PrivateClauseOp PrivateClauseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, ::mlir::omp::DataSharingClauseTypeAttr data_sharing_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type), std::forward<decltype(data_sharing_type)>(data_sharing_type));
|
|
}
|
|
|
|
void PrivateClauseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, ::mlir::Type type, ::mlir::omp::DataSharingClauseType data_sharing_type) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
|
|
odsState.getOrAddProperties<Properties>().type = ::mlir::TypeAttr::get(type);
|
|
odsState.getOrAddProperties<Properties>().data_sharing_type = ::mlir::omp::DataSharingClauseTypeAttr::get(odsBuilder.getContext(), data_sharing_type);
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
PrivateClauseOp PrivateClauseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llvm::StringRef sym_name, ::mlir::Type type, ::mlir::omp::DataSharingClauseType data_sharing_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type), std::forward<decltype(data_sharing_type)>(data_sharing_type));
|
|
auto __res__ = ::llvm::dyn_cast<PrivateClauseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
PrivateClauseOp PrivateClauseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llvm::StringRef sym_name, ::mlir::Type type, ::mlir::omp::DataSharingClauseType data_sharing_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type), std::forward<decltype(data_sharing_type)>(data_sharing_type));
|
|
}
|
|
|
|
void PrivateClauseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type, ::mlir::omp::DataSharingClauseType data_sharing_type) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
|
|
odsState.getOrAddProperties<Properties>().type = ::mlir::TypeAttr::get(type);
|
|
odsState.getOrAddProperties<Properties>().data_sharing_type = ::mlir::omp::DataSharingClauseTypeAttr::get(odsBuilder.getContext(), data_sharing_type);
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
PrivateClauseOp PrivateClauseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type, ::mlir::omp::DataSharingClauseType data_sharing_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type), std::forward<decltype(data_sharing_type)>(data_sharing_type));
|
|
auto __res__ = ::llvm::dyn_cast<PrivateClauseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
PrivateClauseOp PrivateClauseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type, ::mlir::omp::DataSharingClauseType data_sharing_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(type)>(type), std::forward<decltype(data_sharing_type)>(data_sharing_type));
|
|
}
|
|
|
|
void PrivateClauseOp::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<PrivateClauseOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
PrivateClauseOp PrivateClauseOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<PrivateClauseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
PrivateClauseOp PrivateClauseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void PrivateClauseOp::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&>(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);
|
|
}
|
|
|
|
PrivateClauseOp PrivateClauseOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<PrivateClauseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
PrivateClauseOp PrivateClauseOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult PrivateClauseOp::verifyInvariantsImpl() {
|
|
auto tblgen_data_sharing_type = getProperties().data_sharing_type; (void)tblgen_data_sharing_type;
|
|
if (!tblgen_data_sharing_type) return emitOpError("requires attribute 'data_sharing_type'");
|
|
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_OpenMPOps8(*this, tblgen_sym_name, "sym_name")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps28(*this, tblgen_type, "type")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps29(*this, tblgen_data_sharing_type, "data_sharing_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_OpenMPOps2(*this, region, "init_region", index++)))
|
|
return ::mlir::failure();
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps2(*this, region, "copy_region", index++)))
|
|
return ::mlir::failure();
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(2)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps2(*this, region, "dealloc_region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult PrivateClauseOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult PrivateClauseOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::omp::DataSharingClauseTypeAttr data_sharing_typeAttr;
|
|
::mlir::StringAttr sym_nameAttr;
|
|
::mlir::TypeAttr typeAttr;
|
|
std::unique_ptr<::mlir::Region> init_regionRegion = std::make_unique<::mlir::Region>();
|
|
std::unique_ptr<::mlir::Region> copy_regionRegion = std::make_unique<::mlir::Region>();
|
|
std::unique_ptr<::mlir::Region> dealloc_regionRegion = std::make_unique<::mlir::Region>();
|
|
|
|
if (parser.parseCustomAttributeWithFallback(data_sharing_typeAttr, ::mlir::Type{})) {
|
|
return ::mlir::failure();
|
|
}
|
|
if (data_sharing_typeAttr) result.getOrAddProperties<PrivateClauseOp::Properties>().data_sharing_type = data_sharing_typeAttr;
|
|
|
|
if (parser.parseSymbolName(sym_nameAttr))
|
|
return ::mlir::failure();
|
|
if (sym_nameAttr) result.getOrAddProperties<PrivateClauseOp::Properties>().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<PrivateClauseOp::Properties>().type = typeAttr;
|
|
if (::mlir::succeeded(parser.parseOptionalKeyword("init"))) {
|
|
|
|
if (parser.parseRegion(*init_regionRegion))
|
|
return ::mlir::failure();
|
|
}
|
|
if (::mlir::succeeded(parser.parseOptionalKeyword("copy"))) {
|
|
|
|
if (parser.parseRegion(*copy_regionRegion))
|
|
return ::mlir::failure();
|
|
}
|
|
if (::mlir::succeeded(parser.parseOptionalKeyword("dealloc"))) {
|
|
|
|
if (parser.parseRegion(*dealloc_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(init_regionRegion));
|
|
result.addRegion(std::move(copy_regionRegion));
|
|
result.addRegion(std::move(dealloc_regionRegion));
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void PrivateClauseOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printStrippedAttrOrType(getDataSharingTypeAttr());
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printSymbolName(getSymNameAttr().getValue());
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printAttributeWithoutType(getTypeAttr());
|
|
if (!getInitRegion().empty()) {
|
|
_odsPrinter << ' ' << "init";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getInitRegion());
|
|
}
|
|
if (!getCopyRegion().empty()) {
|
|
_odsPrinter << ' ' << "copy";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getCopyRegion());
|
|
}
|
|
if (!getDeallocRegion().empty()) {
|
|
_odsPrinter << ' ' << "dealloc";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getDeallocRegion());
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("data_sharing_type");
|
|
elidedAttrs.push_back("sym_name");
|
|
elidedAttrs.push_back("type");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::PrivateClauseOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::PrivateClauseOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::ScanOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ScanOpGenericAdaptorBase::ScanOpGenericAdaptorBase(ScanOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> ScanOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ScanOpAdaptor::ScanOpAdaptor(ScanOp op) : ScanOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ScanOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> ScanOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange ScanOp::getInclusiveVarsMutable() {
|
|
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 ScanOp::getExclusiveVarsMutable() {
|
|
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 ScanOp::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 ScanOp::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 ScanOp::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<mlir::Attribute> ScanOp::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 ScanOp::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 ScanOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult ScanOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ScanOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(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 ScanOp::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));
|
|
;
|
|
}
|
|
}
|
|
|
|
ScanOp ScanOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const ScanOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<ScanOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ScanOp ScanOp::create(::mlir::ImplicitLocOpBuilder &builder, const ScanOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void ScanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inclusive_vars, ::mlir::ValueRange exclusive_vars) {
|
|
odsState.addOperands(inclusive_vars);
|
|
odsState.addOperands(exclusive_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(inclusive_vars.size()), static_cast<int32_t>(exclusive_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
}
|
|
|
|
ScanOp ScanOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange inclusive_vars, ::mlir::ValueRange exclusive_vars) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(inclusive_vars)>(inclusive_vars), std::forward<decltype(exclusive_vars)>(exclusive_vars));
|
|
auto __res__ = ::llvm::dyn_cast<ScanOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ScanOp ScanOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange inclusive_vars, ::mlir::ValueRange exclusive_vars) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(inclusive_vars)>(inclusive_vars), std::forward<decltype(exclusive_vars)>(exclusive_vars));
|
|
}
|
|
|
|
void ScanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inclusive_vars, ::mlir::ValueRange exclusive_vars) {
|
|
odsState.addOperands(inclusive_vars);
|
|
odsState.addOperands(exclusive_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(inclusive_vars.size()), static_cast<int32_t>(exclusive_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ScanOp ScanOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inclusive_vars, ::mlir::ValueRange exclusive_vars) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(inclusive_vars)>(inclusive_vars), std::forward<decltype(exclusive_vars)>(exclusive_vars));
|
|
auto __res__ = ::llvm::dyn_cast<ScanOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ScanOp ScanOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inclusive_vars, ::mlir::ValueRange exclusive_vars) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(inclusive_vars)>(inclusive_vars), std::forward<decltype(exclusive_vars)>(exclusive_vars));
|
|
}
|
|
|
|
void ScanOp::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<ScanOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
ScanOp ScanOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<ScanOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ScanOp ScanOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void ScanOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ScanOp ScanOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<ScanOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ScanOp ScanOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult ScanOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ScanOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult ScanOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> inclusive_varsOperands;
|
|
::llvm::SMLoc inclusive_varsOperandsLoc;
|
|
(void)inclusive_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> inclusive_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> exclusive_varsOperands;
|
|
::llvm::SMLoc exclusive_varsOperandsLoc;
|
|
(void)exclusive_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> exclusive_varsTypes;
|
|
bool inclusiveClause = false;
|
|
bool exclusiveClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("inclusive"))) {
|
|
|
|
if (inclusiveClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`inclusive` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
inclusiveClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
inclusive_varsOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(inclusive_varsOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(inclusive_varsTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("exclusive"))) {
|
|
|
|
if (exclusiveClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`exclusive` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
exclusiveClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
exclusive_varsOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(exclusive_varsOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(exclusive_varsTypes))
|
|
return ::mlir::failure();
|
|
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<int32_t>({static_cast<int32_t>(inclusive_varsOperands.size()), static_cast<int32_t>(exclusive_varsOperands.size())}), result.getOrAddProperties<ScanOp::Properties>().operandSegmentSizes.begin());
|
|
if (parser.resolveOperands(inclusive_varsOperands, inclusive_varsTypes, inclusive_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(exclusive_varsOperands, exclusive_varsTypes, exclusive_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ScanOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getInclusiveVars().size()) {
|
|
_odsPrinter << ' ' << "inclusive";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getInclusiveVars();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getInclusiveVars().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getExclusiveVars().size()) {
|
|
_odsPrinter << ' ' << "exclusive";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getExclusiveVars();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getExclusiveVars().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
void ScanOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::SideEffects::DefaultResource::get());
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::ScanOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::ScanOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::ScopeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ScopeOpGenericAdaptorBase::ScopeOpGenericAdaptorBase(ScopeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> ScopeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::UnitAttr ScopeOpGenericAdaptorBase::getNowaitAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nowait);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool ScopeOpGenericAdaptorBase::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > ScopeOpGenericAdaptorBase::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr ScopeOpGenericAdaptorBase::getPrivateNeedsBarrierAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().private_needs_barrier);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool ScopeOpGenericAdaptorBase::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ReductionModifier> ScopeOpGenericAdaptorBase::getReductionMod() {
|
|
auto attr = getReductionModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ReductionModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> ScopeOpGenericAdaptorBase::getReductionByref() {
|
|
auto attr = getReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > ScopeOpGenericAdaptorBase::getReductionSyms() {
|
|
auto attr = getReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ScopeOpAdaptor::ScopeOpAdaptor(ScopeOp op) : ScopeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ScopeOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_reduction_byref = getProperties().reduction_byref; (void)tblgen_reduction_byref;
|
|
auto tblgen_reduction_mod = getProperties().reduction_mod; (void)tblgen_reduction_mod;
|
|
auto tblgen_reduction_syms = getProperties().reduction_syms; (void)tblgen_reduction_syms;
|
|
|
|
if (tblgen_nowait && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nowait))))
|
|
return emitError(loc, "'omp.scope' op attribute 'nowait' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_private_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_private_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_private_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.scope' op attribute 'private_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_private_needs_barrier && !((::llvm::isa<::mlir::UnitAttr>(tblgen_private_needs_barrier))))
|
|
return emitError(loc, "'omp.scope' op attribute 'private_needs_barrier' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_reduction_mod && !((::llvm::isa<::mlir::omp::ReductionModifierAttr>(tblgen_reduction_mod))))
|
|
return emitError(loc, "'omp.scope' op attribute 'reduction_mod' failed to satisfy constraint: reduction modifier");
|
|
|
|
if (tblgen_reduction_byref && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(tblgen_reduction_byref))))
|
|
return emitError(loc, "'omp.scope' op attribute 'reduction_byref' failed to satisfy constraint: i1 dense array attribute");
|
|
|
|
if (tblgen_reduction_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_reduction_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_reduction_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.scope' op attribute 'reduction_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> ScopeOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange ScopeOp::getAllocateVarsMutable() {
|
|
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 ScopeOp::getAllocatorVarsMutable() {
|
|
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 ScopeOp::getPrivateVarsMutable() {
|
|
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 ScopeOp::getReductionVarsMutable() {
|
|
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 ScopeOp::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.nowait;
|
|
auto attr = dict.get("nowait");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nowait` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_needs_barrier;
|
|
auto attr = dict.get("private_needs_barrier");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_needs_barrier` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_syms;
|
|
auto attr = dict.get("private_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_syms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_byref;
|
|
auto attr = dict.get("reduction_byref");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_byref` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_mod;
|
|
auto attr = dict.get("reduction_mod");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_mod` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_syms;
|
|
auto attr = dict.get("reduction_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_syms` 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 ScopeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.nowait;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nowait",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_needs_barrier;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_needs_barrier",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_syms",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_byref;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_byref",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_mod;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_mod",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_syms",
|
|
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 ScopeOp::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.nowait.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_needs_barrier.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_syms.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_byref.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_mod.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_syms.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ScopeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "nowait")
|
|
return prop.nowait;
|
|
|
|
if (name == "private_needs_barrier")
|
|
return prop.private_needs_barrier;
|
|
|
|
if (name == "private_syms")
|
|
return prop.private_syms;
|
|
|
|
if (name == "reduction_byref")
|
|
return prop.reduction_byref;
|
|
|
|
if (name == "reduction_mod")
|
|
return prop.reduction_mod;
|
|
|
|
if (name == "reduction_syms")
|
|
return prop.reduction_syms;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ScopeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "nowait") {
|
|
prop.nowait = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nowait)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_needs_barrier") {
|
|
prop.private_needs_barrier = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_needs_barrier)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_syms") {
|
|
prop.private_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_syms)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_byref") {
|
|
prop.reduction_byref = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_byref)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_mod") {
|
|
prop.reduction_mod = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_mod)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_syms") {
|
|
prop.reduction_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_syms)>>(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 ScopeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.nowait) attrs.append("nowait", prop.nowait);
|
|
|
|
if (prop.private_needs_barrier) attrs.append("private_needs_barrier", prop.private_needs_barrier);
|
|
|
|
if (prop.private_syms) attrs.append("private_syms", prop.private_syms);
|
|
|
|
if (prop.reduction_byref) attrs.append("reduction_byref", prop.reduction_byref);
|
|
|
|
if (prop.reduction_mod) attrs.append("reduction_mod", prop.reduction_mod);
|
|
|
|
if (prop.reduction_syms) attrs.append("reduction_syms", prop.reduction_syms);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult ScopeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNowaitAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "nowait", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateNeedsBarrierAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "private_needs_barrier", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "private_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionByrefAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(attr, "reduction_byref", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionModAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps19(attr, "reduction_mod", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "reduction_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ScopeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nowait)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_needs_barrier)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_syms)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_byref)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_mod)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_syms)))
|
|
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 ScopeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.nowait);
|
|
|
|
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
|
|
}
|
|
|
|
writer.writeOptionalAttribute(prop.private_needs_barrier);
|
|
|
|
writer.writeOptionalAttribute(prop.private_syms);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_byref);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_mod);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_syms);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
bool ScopeOp::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > ScopeOp::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool ScopeOp::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ReductionModifier> ScopeOp::getReductionMod() {
|
|
auto attr = getReductionModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ReductionModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> ScopeOp::getReductionByref() {
|
|
auto attr = getReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > ScopeOp::getReductionSyms() {
|
|
auto attr = getReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
void ScopeOp::setNowait(bool attrValue) {
|
|
auto &odsProp = getProperties().nowait;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void ScopeOp::setPrivateNeedsBarrier(bool attrValue) {
|
|
auto &odsProp = getProperties().private_needs_barrier;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void ScopeOp::setReductionMod(::std::optional<::mlir::omp::ReductionModifier> attrValue) {
|
|
auto &odsProp = getProperties().reduction_mod;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ReductionModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void ScopeOp::setReductionByref(::std::optional<::llvm::ArrayRef<bool>> attrValue) {
|
|
auto &odsProp = getProperties().reduction_byref;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getDenseBoolArrayAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
ScopeOp ScopeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const ScopeOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<ScopeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ScopeOp ScopeOp::create(::mlir::ImplicitLocOpBuilder &builder, const ScopeOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void ScopeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
ScopeOp ScopeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<ScopeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ScopeOp ScopeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
}
|
|
|
|
void ScopeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ScopeOp ScopeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<ScopeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ScopeOp ScopeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
}
|
|
|
|
void ScopeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
ScopeOp ScopeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<ScopeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ScopeOp ScopeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
}
|
|
|
|
void ScopeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ScopeOp ScopeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<ScopeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ScopeOp ScopeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
}
|
|
|
|
void ScopeOp::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<ScopeOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
ScopeOp ScopeOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<ScopeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ScopeOp ScopeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void ScopeOp::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&>(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);
|
|
}
|
|
|
|
ScopeOp ScopeOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<ScopeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ScopeOp ScopeOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult ScopeOp::verifyInvariantsImpl() {
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_reduction_byref = getProperties().reduction_byref; (void)tblgen_reduction_byref;
|
|
auto tblgen_reduction_mod = getProperties().reduction_mod; (void)tblgen_reduction_mod;
|
|
auto tblgen_reduction_syms = getProperties().reduction_syms; (void)tblgen_reduction_syms;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_nowait, "nowait")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_private_syms, "private_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_private_needs_barrier, "private_needs_barrier")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps19(*this, tblgen_reduction_mod, "reduction_mod")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(*this, tblgen_reduction_byref, "reduction_byref")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_reduction_syms, "reduction_syms")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*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_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ScopeOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult ScopeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocate_varsOperands;
|
|
::llvm::SMLoc allocate_varsOperandsLoc;
|
|
(void)allocate_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocate_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocator_varsOperands;
|
|
::llvm::SMLoc allocator_varsOperandsLoc;
|
|
(void)allocator_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocator_varsTypes;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> private_varsOperands;
|
|
::llvm::SMLoc private_varsOperandsLoc;
|
|
(void)private_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> private_varsTypes;
|
|
::mlir::ArrayAttr private_symsAttr;
|
|
::mlir::UnitAttr private_needs_barrierAttr;
|
|
::mlir::omp::ReductionModifierAttr reduction_modAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> reduction_varsOperands;
|
|
::llvm::SMLoc reduction_varsOperandsLoc;
|
|
(void)reduction_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> reduction_varsTypes;
|
|
::mlir::DenseBoolArrayAttr reduction_byrefAttr;
|
|
::mlir::ArrayAttr reduction_symsAttr;
|
|
bool allocateClause = false;
|
|
bool nowaitClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("allocate"))) {
|
|
|
|
if (allocateClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`allocate` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
allocateClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
allocate_varsOperandsLoc = parser.getCurrentLocation();
|
|
allocator_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseAllocateAndAllocator(parser, allocate_varsOperands, allocate_varsTypes, allocator_varsOperands, allocator_varsTypes);
|
|
if (odsResult) return ::mlir::failure();
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("nowait"))) {
|
|
|
|
if (nowaitClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`nowait` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
nowaitClause = true;
|
|
result.getOrAddProperties<ScopeOp::Properties>().nowait = parser.getBuilder().getUnitAttr(); } else {
|
|
break;
|
|
}
|
|
}
|
|
{
|
|
private_varsOperandsLoc = parser.getCurrentLocation();
|
|
reduction_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parsePrivateReductionRegion(parser, *regionRegion, private_varsOperands, private_varsTypes, private_symsAttr, private_needs_barrierAttr, reduction_modAttr, reduction_varsOperands, reduction_varsTypes, reduction_byrefAttr, reduction_symsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (private_symsAttr)
|
|
result.getOrAddProperties<ScopeOp::Properties>().private_syms = private_symsAttr;
|
|
if (private_needs_barrierAttr)
|
|
result.getOrAddProperties<ScopeOp::Properties>().private_needs_barrier = private_needs_barrierAttr;
|
|
if (reduction_modAttr)
|
|
result.getOrAddProperties<ScopeOp::Properties>().reduction_mod = reduction_modAttr;
|
|
if (reduction_byrefAttr)
|
|
result.getOrAddProperties<ScopeOp::Properties>().reduction_byref = reduction_byrefAttr;
|
|
if (reduction_symsAttr)
|
|
result.getOrAddProperties<ScopeOp::Properties>().reduction_syms = reduction_symsAttr;
|
|
}
|
|
{
|
|
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<int32_t>({static_cast<int32_t>(allocate_varsOperands.size()), static_cast<int32_t>(allocator_varsOperands.size()), static_cast<int32_t>(private_varsOperands.size()), static_cast<int32_t>(reduction_varsOperands.size())}), result.getOrAddProperties<ScopeOp::Properties>().operandSegmentSizes.begin());
|
|
if (parser.resolveOperands(allocate_varsOperands, allocate_varsTypes, allocate_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(allocator_varsOperands, allocator_varsTypes, allocator_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(private_varsOperands, private_varsTypes, private_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(reduction_varsOperands, reduction_varsTypes, reduction_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ScopeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getAllocateVars().size() || getAllocatorVars().size()) {
|
|
_odsPrinter << ' ' << "allocate";
|
|
_odsPrinter << "(";
|
|
printAllocateAndAllocator(_odsPrinter, *this, getAllocateVars(), getAllocateVars().getTypes(), getAllocatorVars(), getAllocatorVars().getTypes());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getNowaitAttr() && getNowaitAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "nowait";
|
|
}
|
|
_odsPrinter << ' ';
|
|
printPrivateReductionRegion(_odsPrinter, *this, getRegion(), getPrivateVars(), getPrivateVars().getTypes(), getPrivateSymsAttr(), getPrivateNeedsBarrierAttr(), getReductionModAttr(), getReductionVars(), getReductionVars().getTypes(), getReductionByrefAttr(), getReductionSymsAttr());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("nowait");
|
|
elidedAttrs.push_back("private_syms");
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
elidedAttrs.push_back("reduction_mod");
|
|
elidedAttrs.push_back("reduction_byref");
|
|
elidedAttrs.push_back("reduction_syms");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getNowaitAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("nowait");
|
|
}
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getPrivateNeedsBarrierAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::ScopeOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::ScopeOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::SectionOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
SectionOpGenericAdaptorBase::SectionOpGenericAdaptorBase(SectionOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
SectionOpAdaptor::SectionOpAdaptor(SectionOp op) : SectionOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult SectionOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SectionOp::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 SectionOp::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 SectionOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> SectionOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void SectionOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void SectionOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult SectionOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SectionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) {
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
SectionOp SectionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__);
|
|
auto __res__ = ::llvm::dyn_cast<SectionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SectionOp SectionOp::create(::mlir::ImplicitLocOpBuilder &builder) {
|
|
return create(builder, builder.getLoc());
|
|
}
|
|
|
|
void SectionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) {
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SectionOp SectionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes));
|
|
auto __res__ = ::llvm::dyn_cast<SectionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SectionOp SectionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes));
|
|
}
|
|
|
|
void SectionOp::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);
|
|
}
|
|
|
|
SectionOp SectionOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<SectionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SectionOp SectionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void SectionOp::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&>(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);
|
|
}
|
|
|
|
SectionOp SectionOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<SectionOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SectionOp SectionOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult SectionOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SectionOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult SectionOp::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 SectionOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getRegion());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::SectionOp)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::SectionsOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
SectionsOpGenericAdaptorBase::SectionsOpGenericAdaptorBase(SectionsOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> SectionsOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::UnitAttr SectionsOpGenericAdaptorBase::getNowaitAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nowait);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool SectionsOpGenericAdaptorBase::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SectionsOpGenericAdaptorBase::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr SectionsOpGenericAdaptorBase::getPrivateNeedsBarrierAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().private_needs_barrier);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool SectionsOpGenericAdaptorBase::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ReductionModifier> SectionsOpGenericAdaptorBase::getReductionMod() {
|
|
auto attr = getReductionModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ReductionModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> SectionsOpGenericAdaptorBase::getReductionByref() {
|
|
auto attr = getReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SectionsOpGenericAdaptorBase::getReductionSyms() {
|
|
auto attr = getReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
SectionsOpAdaptor::SectionsOpAdaptor(SectionsOp op) : SectionsOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult SectionsOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_reduction_byref = getProperties().reduction_byref; (void)tblgen_reduction_byref;
|
|
auto tblgen_reduction_mod = getProperties().reduction_mod; (void)tblgen_reduction_mod;
|
|
auto tblgen_reduction_syms = getProperties().reduction_syms; (void)tblgen_reduction_syms;
|
|
|
|
if (tblgen_nowait && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nowait))))
|
|
return emitError(loc, "'omp.sections' op attribute 'nowait' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_private_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_private_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_private_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.sections' op attribute 'private_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_private_needs_barrier && !((::llvm::isa<::mlir::UnitAttr>(tblgen_private_needs_barrier))))
|
|
return emitError(loc, "'omp.sections' op attribute 'private_needs_barrier' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_reduction_mod && !((::llvm::isa<::mlir::omp::ReductionModifierAttr>(tblgen_reduction_mod))))
|
|
return emitError(loc, "'omp.sections' op attribute 'reduction_mod' failed to satisfy constraint: reduction modifier");
|
|
|
|
if (tblgen_reduction_byref && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(tblgen_reduction_byref))))
|
|
return emitError(loc, "'omp.sections' op attribute 'reduction_byref' failed to satisfy constraint: i1 dense array attribute");
|
|
|
|
if (tblgen_reduction_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_reduction_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_reduction_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.sections' op attribute 'reduction_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> SectionsOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange SectionsOp::getAllocateVarsMutable() {
|
|
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 SectionsOp::getAllocatorVarsMutable() {
|
|
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 SectionsOp::getPrivateVarsMutable() {
|
|
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 SectionsOp::getReductionVarsMutable() {
|
|
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 SectionsOp::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.nowait;
|
|
auto attr = dict.get("nowait");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nowait` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_needs_barrier;
|
|
auto attr = dict.get("private_needs_barrier");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_needs_barrier` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_syms;
|
|
auto attr = dict.get("private_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_syms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_byref;
|
|
auto attr = dict.get("reduction_byref");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_byref` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_mod;
|
|
auto attr = dict.get("reduction_mod");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_mod` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_syms;
|
|
auto attr = dict.get("reduction_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_syms` 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 SectionsOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.nowait;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nowait",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_needs_barrier;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_needs_barrier",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_syms",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_byref;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_byref",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_mod;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_mod",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_syms",
|
|
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 SectionsOp::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.nowait.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_needs_barrier.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_syms.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_byref.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_mod.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_syms.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> SectionsOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "nowait")
|
|
return prop.nowait;
|
|
|
|
if (name == "private_needs_barrier")
|
|
return prop.private_needs_barrier;
|
|
|
|
if (name == "private_syms")
|
|
return prop.private_syms;
|
|
|
|
if (name == "reduction_byref")
|
|
return prop.reduction_byref;
|
|
|
|
if (name == "reduction_mod")
|
|
return prop.reduction_mod;
|
|
|
|
if (name == "reduction_syms")
|
|
return prop.reduction_syms;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void SectionsOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "nowait") {
|
|
prop.nowait = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nowait)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_needs_barrier") {
|
|
prop.private_needs_barrier = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_needs_barrier)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_syms") {
|
|
prop.private_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_syms)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_byref") {
|
|
prop.reduction_byref = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_byref)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_mod") {
|
|
prop.reduction_mod = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_mod)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_syms") {
|
|
prop.reduction_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_syms)>>(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 SectionsOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.nowait) attrs.append("nowait", prop.nowait);
|
|
|
|
if (prop.private_needs_barrier) attrs.append("private_needs_barrier", prop.private_needs_barrier);
|
|
|
|
if (prop.private_syms) attrs.append("private_syms", prop.private_syms);
|
|
|
|
if (prop.reduction_byref) attrs.append("reduction_byref", prop.reduction_byref);
|
|
|
|
if (prop.reduction_mod) attrs.append("reduction_mod", prop.reduction_mod);
|
|
|
|
if (prop.reduction_syms) attrs.append("reduction_syms", prop.reduction_syms);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult SectionsOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNowaitAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "nowait", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateNeedsBarrierAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "private_needs_barrier", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "private_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionByrefAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(attr, "reduction_byref", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionModAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps19(attr, "reduction_mod", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "reduction_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SectionsOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nowait)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_needs_barrier)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_syms)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_byref)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_mod)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_syms)))
|
|
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 SectionsOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.nowait);
|
|
|
|
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
|
|
}
|
|
|
|
writer.writeOptionalAttribute(prop.private_needs_barrier);
|
|
|
|
writer.writeOptionalAttribute(prop.private_syms);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_byref);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_mod);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_syms);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
bool SectionsOp::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SectionsOp::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool SectionsOp::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ReductionModifier> SectionsOp::getReductionMod() {
|
|
auto attr = getReductionModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ReductionModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> SectionsOp::getReductionByref() {
|
|
auto attr = getReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SectionsOp::getReductionSyms() {
|
|
auto attr = getReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
void SectionsOp::setNowait(bool attrValue) {
|
|
auto &odsProp = getProperties().nowait;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void SectionsOp::setPrivateNeedsBarrier(bool attrValue) {
|
|
auto &odsProp = getProperties().private_needs_barrier;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void SectionsOp::setReductionMod(::std::optional<::mlir::omp::ReductionModifier> attrValue) {
|
|
auto &odsProp = getProperties().reduction_mod;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ReductionModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void SectionsOp::setReductionByref(::std::optional<::llvm::ArrayRef<bool>> attrValue) {
|
|
auto &odsProp = getProperties().reduction_byref;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getDenseBoolArrayAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
SectionsOp SectionsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const SectionsOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<SectionsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SectionsOp SectionsOp::create(::mlir::ImplicitLocOpBuilder &builder, const SectionsOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void SectionsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
SectionsOp SectionsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<SectionsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SectionsOp SectionsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
}
|
|
|
|
void SectionsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SectionsOp SectionsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<SectionsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SectionsOp SectionsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
}
|
|
|
|
void SectionsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
SectionsOp SectionsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<SectionsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SectionsOp SectionsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
}
|
|
|
|
void SectionsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SectionsOp SectionsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<SectionsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SectionsOp SectionsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms));
|
|
}
|
|
|
|
void SectionsOp::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<SectionsOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
SectionsOp SectionsOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<SectionsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SectionsOp SectionsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void SectionsOp::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&>(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);
|
|
}
|
|
|
|
SectionsOp SectionsOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<SectionsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SectionsOp SectionsOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult SectionsOp::verifyInvariantsImpl() {
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_reduction_byref = getProperties().reduction_byref; (void)tblgen_reduction_byref;
|
|
auto tblgen_reduction_mod = getProperties().reduction_mod; (void)tblgen_reduction_mod;
|
|
auto tblgen_reduction_syms = getProperties().reduction_syms; (void)tblgen_reduction_syms;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_nowait, "nowait")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_private_syms, "private_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_private_needs_barrier, "private_needs_barrier")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps19(*this, tblgen_reduction_mod, "reduction_mod")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(*this, tblgen_reduction_byref, "reduction_byref")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_reduction_syms, "reduction_syms")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*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_OpenMPOps1(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SectionsOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult SectionsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocate_varsOperands;
|
|
::llvm::SMLoc allocate_varsOperandsLoc;
|
|
(void)allocate_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocate_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocator_varsOperands;
|
|
::llvm::SMLoc allocator_varsOperandsLoc;
|
|
(void)allocator_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocator_varsTypes;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> private_varsOperands;
|
|
::llvm::SMLoc private_varsOperandsLoc;
|
|
(void)private_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> private_varsTypes;
|
|
::mlir::ArrayAttr private_symsAttr;
|
|
::mlir::UnitAttr private_needs_barrierAttr;
|
|
::mlir::omp::ReductionModifierAttr reduction_modAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> reduction_varsOperands;
|
|
::llvm::SMLoc reduction_varsOperandsLoc;
|
|
(void)reduction_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> reduction_varsTypes;
|
|
::mlir::DenseBoolArrayAttr reduction_byrefAttr;
|
|
::mlir::ArrayAttr reduction_symsAttr;
|
|
bool allocateClause = false;
|
|
bool nowaitClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("allocate"))) {
|
|
|
|
if (allocateClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`allocate` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
allocateClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
allocate_varsOperandsLoc = parser.getCurrentLocation();
|
|
allocator_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseAllocateAndAllocator(parser, allocate_varsOperands, allocate_varsTypes, allocator_varsOperands, allocator_varsTypes);
|
|
if (odsResult) return ::mlir::failure();
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("nowait"))) {
|
|
|
|
if (nowaitClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`nowait` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
nowaitClause = true;
|
|
result.getOrAddProperties<SectionsOp::Properties>().nowait = parser.getBuilder().getUnitAttr(); } else {
|
|
break;
|
|
}
|
|
}
|
|
{
|
|
private_varsOperandsLoc = parser.getCurrentLocation();
|
|
reduction_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parsePrivateReductionRegion(parser, *regionRegion, private_varsOperands, private_varsTypes, private_symsAttr, private_needs_barrierAttr, reduction_modAttr, reduction_varsOperands, reduction_varsTypes, reduction_byrefAttr, reduction_symsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (private_symsAttr)
|
|
result.getOrAddProperties<SectionsOp::Properties>().private_syms = private_symsAttr;
|
|
if (private_needs_barrierAttr)
|
|
result.getOrAddProperties<SectionsOp::Properties>().private_needs_barrier = private_needs_barrierAttr;
|
|
if (reduction_modAttr)
|
|
result.getOrAddProperties<SectionsOp::Properties>().reduction_mod = reduction_modAttr;
|
|
if (reduction_byrefAttr)
|
|
result.getOrAddProperties<SectionsOp::Properties>().reduction_byref = reduction_byrefAttr;
|
|
if (reduction_symsAttr)
|
|
result.getOrAddProperties<SectionsOp::Properties>().reduction_syms = reduction_symsAttr;
|
|
}
|
|
{
|
|
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<int32_t>({static_cast<int32_t>(allocate_varsOperands.size()), static_cast<int32_t>(allocator_varsOperands.size()), static_cast<int32_t>(private_varsOperands.size()), static_cast<int32_t>(reduction_varsOperands.size())}), result.getOrAddProperties<SectionsOp::Properties>().operandSegmentSizes.begin());
|
|
if (parser.resolveOperands(allocate_varsOperands, allocate_varsTypes, allocate_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(allocator_varsOperands, allocator_varsTypes, allocator_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(private_varsOperands, private_varsTypes, private_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(reduction_varsOperands, reduction_varsTypes, reduction_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SectionsOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getAllocateVars().size() || getAllocatorVars().size()) {
|
|
_odsPrinter << ' ' << "allocate";
|
|
_odsPrinter << "(";
|
|
printAllocateAndAllocator(_odsPrinter, *this, getAllocateVars(), getAllocateVars().getTypes(), getAllocatorVars(), getAllocatorVars().getTypes());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getNowaitAttr() && getNowaitAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "nowait";
|
|
}
|
|
_odsPrinter << ' ';
|
|
printPrivateReductionRegion(_odsPrinter, *this, getRegion(), getPrivateVars(), getPrivateVars().getTypes(), getPrivateSymsAttr(), getPrivateNeedsBarrierAttr(), getReductionModAttr(), getReductionVars(), getReductionVars().getTypes(), getReductionByrefAttr(), getReductionSymsAttr());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("nowait");
|
|
elidedAttrs.push_back("private_syms");
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
elidedAttrs.push_back("reduction_mod");
|
|
elidedAttrs.push_back("reduction_byref");
|
|
elidedAttrs.push_back("reduction_syms");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getNowaitAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("nowait");
|
|
}
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getPrivateNeedsBarrierAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::SectionsOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::SectionsOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::SimdOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
SimdOpGenericAdaptorBase::SimdOpGenericAdaptorBase(SimdOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> SimdOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SimdOpGenericAdaptorBase::getAlignments() {
|
|
auto attr = getAlignmentsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SimdOpGenericAdaptorBase::getLinearVarTypes() {
|
|
auto attr = getLinearVarTypesAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SimdOpGenericAdaptorBase::getLinearModifiers() {
|
|
auto attr = getLinearModifiersAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseOrderKind> SimdOpGenericAdaptorBase::getOrder() {
|
|
auto attr = getOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::OrderModifier> SimdOpGenericAdaptorBase::getOrderMod() {
|
|
auto attr = getOrderModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::OrderModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SimdOpGenericAdaptorBase::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr SimdOpGenericAdaptorBase::getPrivateNeedsBarrierAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().private_needs_barrier);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool SimdOpGenericAdaptorBase::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ReductionModifier> SimdOpGenericAdaptorBase::getReductionMod() {
|
|
auto attr = getReductionModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ReductionModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> SimdOpGenericAdaptorBase::getReductionByref() {
|
|
auto attr = getReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SimdOpGenericAdaptorBase::getReductionSyms() {
|
|
auto attr = getReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<uint64_t> SimdOpGenericAdaptorBase::getSafelen() {
|
|
auto attr = getSafelenAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<uint64_t> SimdOpGenericAdaptorBase::getSimdlen() {
|
|
auto attr = getSimdlenAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
SimdOpAdaptor::SimdOpAdaptor(SimdOp op) : SimdOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult SimdOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_alignments = getProperties().alignments; (void)tblgen_alignments;
|
|
auto tblgen_linear_modifiers = getProperties().linear_modifiers; (void)tblgen_linear_modifiers;
|
|
auto tblgen_linear_var_types = getProperties().linear_var_types; (void)tblgen_linear_var_types;
|
|
auto tblgen_order = getProperties().order; (void)tblgen_order;
|
|
auto tblgen_order_mod = getProperties().order_mod; (void)tblgen_order_mod;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_reduction_byref = getProperties().reduction_byref; (void)tblgen_reduction_byref;
|
|
auto tblgen_reduction_mod = getProperties().reduction_mod; (void)tblgen_reduction_mod;
|
|
auto tblgen_reduction_syms = getProperties().reduction_syms; (void)tblgen_reduction_syms;
|
|
auto tblgen_safelen = getProperties().safelen; (void)tblgen_safelen;
|
|
auto tblgen_simdlen = getProperties().simdlen; (void)tblgen_simdlen;
|
|
|
|
if (tblgen_alignments && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_alignments))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_alignments), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); }))))
|
|
return emitError(loc, "'omp.simd' op attribute 'alignments' failed to satisfy constraint: 64-bit integer array attribute");
|
|
|
|
if (tblgen_linear_var_types && !((::llvm::isa<::mlir::ArrayAttr>(tblgen_linear_var_types))))
|
|
return emitError(loc, "'omp.simd' op attribute 'linear_var_types' failed to satisfy constraint: array attribute");
|
|
|
|
if (tblgen_linear_modifiers && !((::llvm::isa<::mlir::ArrayAttr>(tblgen_linear_modifiers))))
|
|
return emitError(loc, "'omp.simd' op attribute 'linear_modifiers' failed to satisfy constraint: array attribute");
|
|
|
|
if (tblgen_order && !((::llvm::isa<::mlir::omp::ClauseOrderKindAttr>(tblgen_order))))
|
|
return emitError(loc, "'omp.simd' op attribute 'order' failed to satisfy constraint: OrderKind Clause");
|
|
|
|
if (tblgen_order_mod && !((::llvm::isa<::mlir::omp::OrderModifierAttr>(tblgen_order_mod))))
|
|
return emitError(loc, "'omp.simd' op attribute 'order_mod' failed to satisfy constraint: OpenMP Order Modifier");
|
|
|
|
if (tblgen_private_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_private_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_private_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.simd' op attribute 'private_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_private_needs_barrier && !((::llvm::isa<::mlir::UnitAttr>(tblgen_private_needs_barrier))))
|
|
return emitError(loc, "'omp.simd' op attribute 'private_needs_barrier' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_reduction_mod && !((::llvm::isa<::mlir::omp::ReductionModifierAttr>(tblgen_reduction_mod))))
|
|
return emitError(loc, "'omp.simd' op attribute 'reduction_mod' failed to satisfy constraint: reduction modifier");
|
|
|
|
if (tblgen_reduction_byref && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(tblgen_reduction_byref))))
|
|
return emitError(loc, "'omp.simd' op attribute 'reduction_byref' failed to satisfy constraint: i1 dense array attribute");
|
|
|
|
if (tblgen_reduction_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_reduction_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_reduction_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.simd' op attribute 'reduction_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_safelen && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_safelen))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_safelen).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_safelen).getValue().isStrictlyPositive()))))
|
|
return emitError(loc, "'omp.simd' op attribute 'safelen' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive");
|
|
|
|
if (tblgen_simdlen && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_simdlen))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_simdlen).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_simdlen).getValue().isStrictlyPositive()))))
|
|
return emitError(loc, "'omp.simd' op attribute 'simdlen' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> SimdOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange SimdOp::getAlignedVarsMutable() {
|
|
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 SimdOp::getIfExprMutable() {
|
|
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 SimdOp::getLinearVarsMutable() {
|
|
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 SimdOp::getLinearStepVarsMutable() {
|
|
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 SimdOp::getNontemporalVarsMutable() {
|
|
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 SimdOp::getPrivateVarsMutable() {
|
|
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 SimdOp::getReductionVarsMutable() {
|
|
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;
|
|
}
|
|
|
|
::llvm::LogicalResult SimdOp::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.alignments;
|
|
auto attr = dict.get("alignments");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `alignments` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.linear_modifiers;
|
|
auto attr = dict.get("linear_modifiers");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `linear_modifiers` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.linear_var_types;
|
|
auto attr = dict.get("linear_var_types");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `linear_var_types` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.order;
|
|
auto attr = dict.get("order");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `order` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.order_mod;
|
|
auto attr = dict.get("order_mod");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `order_mod` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_needs_barrier;
|
|
auto attr = dict.get("private_needs_barrier");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_needs_barrier` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_syms;
|
|
auto attr = dict.get("private_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_syms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_byref;
|
|
auto attr = dict.get("reduction_byref");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_byref` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_mod;
|
|
auto attr = dict.get("reduction_mod");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_mod` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_syms;
|
|
auto attr = dict.get("reduction_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_syms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.safelen;
|
|
auto attr = dict.get("safelen");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `safelen` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.simdlen;
|
|
auto attr = dict.get("simdlen");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `simdlen` 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 SimdOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.alignments;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("alignments",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.linear_modifiers;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("linear_modifiers",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.linear_var_types;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("linear_var_types",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.order;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("order",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.order_mod;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("order_mod",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_needs_barrier;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_needs_barrier",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_syms",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_byref;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_byref",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_mod;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_mod",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_syms",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.safelen;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("safelen",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.simdlen;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("simdlen",
|
|
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 SimdOp::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.alignments.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.linear_modifiers.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.linear_var_types.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.order.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.order_mod.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_needs_barrier.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_syms.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_byref.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_mod.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_syms.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.safelen.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.simdlen.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> SimdOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "alignments")
|
|
return prop.alignments;
|
|
|
|
if (name == "linear_modifiers")
|
|
return prop.linear_modifiers;
|
|
|
|
if (name == "linear_var_types")
|
|
return prop.linear_var_types;
|
|
|
|
if (name == "order")
|
|
return prop.order;
|
|
|
|
if (name == "order_mod")
|
|
return prop.order_mod;
|
|
|
|
if (name == "private_needs_barrier")
|
|
return prop.private_needs_barrier;
|
|
|
|
if (name == "private_syms")
|
|
return prop.private_syms;
|
|
|
|
if (name == "reduction_byref")
|
|
return prop.reduction_byref;
|
|
|
|
if (name == "reduction_mod")
|
|
return prop.reduction_mod;
|
|
|
|
if (name == "reduction_syms")
|
|
return prop.reduction_syms;
|
|
|
|
if (name == "safelen")
|
|
return prop.safelen;
|
|
|
|
if (name == "simdlen")
|
|
return prop.simdlen;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void SimdOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "alignments") {
|
|
prop.alignments = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.alignments)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "linear_modifiers") {
|
|
prop.linear_modifiers = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.linear_modifiers)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "linear_var_types") {
|
|
prop.linear_var_types = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.linear_var_types)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "order") {
|
|
prop.order = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.order)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "order_mod") {
|
|
prop.order_mod = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.order_mod)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_needs_barrier") {
|
|
prop.private_needs_barrier = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_needs_barrier)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_syms") {
|
|
prop.private_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_syms)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_byref") {
|
|
prop.reduction_byref = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_byref)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_mod") {
|
|
prop.reduction_mod = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_mod)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_syms") {
|
|
prop.reduction_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_syms)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "safelen") {
|
|
prop.safelen = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.safelen)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "simdlen") {
|
|
prop.simdlen = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.simdlen)>>(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 SimdOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.alignments) attrs.append("alignments", prop.alignments);
|
|
|
|
if (prop.linear_modifiers) attrs.append("linear_modifiers", prop.linear_modifiers);
|
|
|
|
if (prop.linear_var_types) attrs.append("linear_var_types", prop.linear_var_types);
|
|
|
|
if (prop.order) attrs.append("order", prop.order);
|
|
|
|
if (prop.order_mod) attrs.append("order_mod", prop.order_mod);
|
|
|
|
if (prop.private_needs_barrier) attrs.append("private_needs_barrier", prop.private_needs_barrier);
|
|
|
|
if (prop.private_syms) attrs.append("private_syms", prop.private_syms);
|
|
|
|
if (prop.reduction_byref) attrs.append("reduction_byref", prop.reduction_byref);
|
|
|
|
if (prop.reduction_mod) attrs.append("reduction_mod", prop.reduction_mod);
|
|
|
|
if (prop.reduction_syms) attrs.append("reduction_syms", prop.reduction_syms);
|
|
|
|
if (prop.safelen) attrs.append("safelen", prop.safelen);
|
|
|
|
if (prop.simdlen) attrs.append("simdlen", prop.simdlen);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult SimdOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAlignmentsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps10(attr, "alignments", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getLinearModifiersAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps11(attr, "linear_modifiers", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getLinearVarTypesAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps11(attr, "linear_var_types", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getOrderAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps12(attr, "order", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getOrderModAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps13(attr, "order_mod", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateNeedsBarrierAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "private_needs_barrier", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "private_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionByrefAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(attr, "reduction_byref", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionModAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps19(attr, "reduction_mod", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "reduction_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getSafelenAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps2(attr, "safelen", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getSimdlenAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps2(attr, "simdlen", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SimdOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.alignments)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.linear_modifiers)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.linear_var_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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.order)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.order_mod)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_needs_barrier)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_syms)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_byref)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_mod)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_syms)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.safelen)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.simdlen)))
|
|
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 SimdOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.alignments);
|
|
|
|
writer.writeOptionalAttribute(prop.linear_modifiers);
|
|
|
|
writer.writeOptionalAttribute(prop.linear_var_types);
|
|
|
|
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
|
|
}
|
|
|
|
writer.writeOptionalAttribute(prop.order);
|
|
|
|
writer.writeOptionalAttribute(prop.order_mod);
|
|
|
|
writer.writeOptionalAttribute(prop.private_needs_barrier);
|
|
|
|
writer.writeOptionalAttribute(prop.private_syms);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_byref);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_mod);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_syms);
|
|
|
|
writer.writeOptionalAttribute(prop.safelen);
|
|
|
|
writer.writeOptionalAttribute(prop.simdlen);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SimdOp::getAlignments() {
|
|
auto attr = getAlignmentsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SimdOp::getLinearVarTypes() {
|
|
auto attr = getLinearVarTypesAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SimdOp::getLinearModifiers() {
|
|
auto attr = getLinearModifiersAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseOrderKind> SimdOp::getOrder() {
|
|
auto attr = getOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::OrderModifier> SimdOp::getOrderMod() {
|
|
auto attr = getOrderModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::OrderModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SimdOp::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool SimdOp::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ReductionModifier> SimdOp::getReductionMod() {
|
|
auto attr = getReductionModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ReductionModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> SimdOp::getReductionByref() {
|
|
auto attr = getReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SimdOp::getReductionSyms() {
|
|
auto attr = getReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<uint64_t> SimdOp::getSafelen() {
|
|
auto attr = getSafelenAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<uint64_t> SimdOp::getSimdlen() {
|
|
auto attr = getSimdlenAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
void SimdOp::setOrder(::std::optional<::mlir::omp::ClauseOrderKind> attrValue) {
|
|
auto &odsProp = getProperties().order;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ClauseOrderKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void SimdOp::setOrderMod(::std::optional<::mlir::omp::OrderModifier> attrValue) {
|
|
auto &odsProp = getProperties().order_mod;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::OrderModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void SimdOp::setPrivateNeedsBarrier(bool attrValue) {
|
|
auto &odsProp = getProperties().private_needs_barrier;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void SimdOp::setReductionMod(::std::optional<::mlir::omp::ReductionModifier> attrValue) {
|
|
auto &odsProp = getProperties().reduction_mod;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ReductionModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void SimdOp::setReductionByref(::std::optional<::llvm::ArrayRef<bool>> attrValue) {
|
|
auto &odsProp = getProperties().reduction_byref;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getDenseBoolArrayAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void SimdOp::setSafelen(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().safelen;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void SimdOp::setSimdlen(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().simdlen;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
SimdOp SimdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const SimdOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<SimdOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SimdOp SimdOp::create(::mlir::ImplicitLocOpBuilder &builder, const SimdOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void SimdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, ::mlir::ValueRange nontemporal_vars, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::IntegerAttr safelen, /*optional*/::mlir::IntegerAttr simdlen) {
|
|
odsState.addOperands(aligned_vars);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(linear_vars);
|
|
odsState.addOperands(linear_step_vars);
|
|
odsState.addOperands(nontemporal_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(aligned_vars.size()), (if_expr ? 1 : 0), static_cast<int32_t>(linear_vars.size()), static_cast<int32_t>(linear_step_vars.size()), static_cast<int32_t>(nontemporal_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (alignments) {
|
|
odsState.getOrAddProperties<Properties>().alignments = alignments;
|
|
}
|
|
if (linear_var_types) {
|
|
odsState.getOrAddProperties<Properties>().linear_var_types = linear_var_types;
|
|
}
|
|
if (linear_modifiers) {
|
|
odsState.getOrAddProperties<Properties>().linear_modifiers = linear_modifiers;
|
|
}
|
|
if (order) {
|
|
odsState.getOrAddProperties<Properties>().order = order;
|
|
}
|
|
if (order_mod) {
|
|
odsState.getOrAddProperties<Properties>().order_mod = order_mod;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
if (safelen) {
|
|
odsState.getOrAddProperties<Properties>().safelen = safelen;
|
|
}
|
|
if (simdlen) {
|
|
odsState.getOrAddProperties<Properties>().simdlen = simdlen;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
SimdOp SimdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, ::mlir::ValueRange nontemporal_vars, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::IntegerAttr safelen, /*optional*/::mlir::IntegerAttr simdlen) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(aligned_vars)>(aligned_vars), std::forward<decltype(alignments)>(alignments), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(nontemporal_vars)>(nontemporal_vars), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(safelen)>(safelen), std::forward<decltype(simdlen)>(simdlen));
|
|
auto __res__ = ::llvm::dyn_cast<SimdOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SimdOp SimdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, ::mlir::ValueRange nontemporal_vars, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::IntegerAttr safelen, /*optional*/::mlir::IntegerAttr simdlen) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(aligned_vars)>(aligned_vars), std::forward<decltype(alignments)>(alignments), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(nontemporal_vars)>(nontemporal_vars), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(safelen)>(safelen), std::forward<decltype(simdlen)>(simdlen));
|
|
}
|
|
|
|
void SimdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, ::mlir::ValueRange nontemporal_vars, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::IntegerAttr safelen, /*optional*/::mlir::IntegerAttr simdlen) {
|
|
odsState.addOperands(aligned_vars);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(linear_vars);
|
|
odsState.addOperands(linear_step_vars);
|
|
odsState.addOperands(nontemporal_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(aligned_vars.size()), (if_expr ? 1 : 0), static_cast<int32_t>(linear_vars.size()), static_cast<int32_t>(linear_step_vars.size()), static_cast<int32_t>(nontemporal_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (alignments) {
|
|
odsState.getOrAddProperties<Properties>().alignments = alignments;
|
|
}
|
|
if (linear_var_types) {
|
|
odsState.getOrAddProperties<Properties>().linear_var_types = linear_var_types;
|
|
}
|
|
if (linear_modifiers) {
|
|
odsState.getOrAddProperties<Properties>().linear_modifiers = linear_modifiers;
|
|
}
|
|
if (order) {
|
|
odsState.getOrAddProperties<Properties>().order = order;
|
|
}
|
|
if (order_mod) {
|
|
odsState.getOrAddProperties<Properties>().order_mod = order_mod;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
if (safelen) {
|
|
odsState.getOrAddProperties<Properties>().safelen = safelen;
|
|
}
|
|
if (simdlen) {
|
|
odsState.getOrAddProperties<Properties>().simdlen = simdlen;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SimdOp SimdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, ::mlir::ValueRange nontemporal_vars, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::IntegerAttr safelen, /*optional*/::mlir::IntegerAttr simdlen) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(aligned_vars)>(aligned_vars), std::forward<decltype(alignments)>(alignments), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(nontemporal_vars)>(nontemporal_vars), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(safelen)>(safelen), std::forward<decltype(simdlen)>(simdlen));
|
|
auto __res__ = ::llvm::dyn_cast<SimdOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SimdOp SimdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, ::mlir::ValueRange nontemporal_vars, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::IntegerAttr safelen, /*optional*/::mlir::IntegerAttr simdlen) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(aligned_vars)>(aligned_vars), std::forward<decltype(alignments)>(alignments), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(nontemporal_vars)>(nontemporal_vars), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(safelen)>(safelen), std::forward<decltype(simdlen)>(simdlen));
|
|
}
|
|
|
|
void SimdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, ::mlir::ValueRange nontemporal_vars, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::IntegerAttr safelen, /*optional*/::mlir::IntegerAttr simdlen) {
|
|
odsState.addOperands(aligned_vars);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(linear_vars);
|
|
odsState.addOperands(linear_step_vars);
|
|
odsState.addOperands(nontemporal_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(aligned_vars.size()), (if_expr ? 1 : 0), static_cast<int32_t>(linear_vars.size()), static_cast<int32_t>(linear_step_vars.size()), static_cast<int32_t>(nontemporal_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (alignments) {
|
|
odsState.getOrAddProperties<Properties>().alignments = alignments;
|
|
}
|
|
if (linear_var_types) {
|
|
odsState.getOrAddProperties<Properties>().linear_var_types = linear_var_types;
|
|
}
|
|
if (linear_modifiers) {
|
|
odsState.getOrAddProperties<Properties>().linear_modifiers = linear_modifiers;
|
|
}
|
|
if (order) {
|
|
odsState.getOrAddProperties<Properties>().order = order;
|
|
}
|
|
if (order_mod) {
|
|
odsState.getOrAddProperties<Properties>().order_mod = order_mod;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
if (safelen) {
|
|
odsState.getOrAddProperties<Properties>().safelen = safelen;
|
|
}
|
|
if (simdlen) {
|
|
odsState.getOrAddProperties<Properties>().simdlen = simdlen;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
SimdOp SimdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, ::mlir::ValueRange nontemporal_vars, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::IntegerAttr safelen, /*optional*/::mlir::IntegerAttr simdlen) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(aligned_vars)>(aligned_vars), std::forward<decltype(alignments)>(alignments), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(nontemporal_vars)>(nontemporal_vars), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(safelen)>(safelen), std::forward<decltype(simdlen)>(simdlen));
|
|
auto __res__ = ::llvm::dyn_cast<SimdOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SimdOp SimdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, ::mlir::ValueRange nontemporal_vars, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::IntegerAttr safelen, /*optional*/::mlir::IntegerAttr simdlen) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(aligned_vars)>(aligned_vars), std::forward<decltype(alignments)>(alignments), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(nontemporal_vars)>(nontemporal_vars), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(safelen)>(safelen), std::forward<decltype(simdlen)>(simdlen));
|
|
}
|
|
|
|
void SimdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, ::mlir::ValueRange nontemporal_vars, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::IntegerAttr safelen, /*optional*/::mlir::IntegerAttr simdlen) {
|
|
odsState.addOperands(aligned_vars);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(linear_vars);
|
|
odsState.addOperands(linear_step_vars);
|
|
odsState.addOperands(nontemporal_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(aligned_vars.size()), (if_expr ? 1 : 0), static_cast<int32_t>(linear_vars.size()), static_cast<int32_t>(linear_step_vars.size()), static_cast<int32_t>(nontemporal_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (alignments) {
|
|
odsState.getOrAddProperties<Properties>().alignments = alignments;
|
|
}
|
|
if (linear_var_types) {
|
|
odsState.getOrAddProperties<Properties>().linear_var_types = linear_var_types;
|
|
}
|
|
if (linear_modifiers) {
|
|
odsState.getOrAddProperties<Properties>().linear_modifiers = linear_modifiers;
|
|
}
|
|
if (order) {
|
|
odsState.getOrAddProperties<Properties>().order = order;
|
|
}
|
|
if (order_mod) {
|
|
odsState.getOrAddProperties<Properties>().order_mod = order_mod;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
if (safelen) {
|
|
odsState.getOrAddProperties<Properties>().safelen = safelen;
|
|
}
|
|
if (simdlen) {
|
|
odsState.getOrAddProperties<Properties>().simdlen = simdlen;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SimdOp SimdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, ::mlir::ValueRange nontemporal_vars, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::IntegerAttr safelen, /*optional*/::mlir::IntegerAttr simdlen) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(aligned_vars)>(aligned_vars), std::forward<decltype(alignments)>(alignments), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(nontemporal_vars)>(nontemporal_vars), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(safelen)>(safelen), std::forward<decltype(simdlen)>(simdlen));
|
|
auto __res__ = ::llvm::dyn_cast<SimdOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SimdOp SimdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange aligned_vars, /*optional*/::mlir::ArrayAttr alignments, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, ::mlir::ValueRange nontemporal_vars, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::IntegerAttr safelen, /*optional*/::mlir::IntegerAttr simdlen) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(aligned_vars)>(aligned_vars), std::forward<decltype(alignments)>(alignments), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(nontemporal_vars)>(nontemporal_vars), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(safelen)>(safelen), std::forward<decltype(simdlen)>(simdlen));
|
|
}
|
|
|
|
void SimdOp::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<SimdOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
SimdOp SimdOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<SimdOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SimdOp SimdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void SimdOp::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&>(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);
|
|
}
|
|
|
|
SimdOp SimdOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<SimdOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SimdOp SimdOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult SimdOp::verifyInvariantsImpl() {
|
|
auto tblgen_alignments = getProperties().alignments; (void)tblgen_alignments;
|
|
auto tblgen_linear_modifiers = getProperties().linear_modifiers; (void)tblgen_linear_modifiers;
|
|
auto tblgen_linear_var_types = getProperties().linear_var_types; (void)tblgen_linear_var_types;
|
|
auto tblgen_order = getProperties().order; (void)tblgen_order;
|
|
auto tblgen_order_mod = getProperties().order_mod; (void)tblgen_order_mod;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_reduction_byref = getProperties().reduction_byref; (void)tblgen_reduction_byref;
|
|
auto tblgen_reduction_mod = getProperties().reduction_mod; (void)tblgen_reduction_mod;
|
|
auto tblgen_reduction_syms = getProperties().reduction_syms; (void)tblgen_reduction_syms;
|
|
auto tblgen_safelen = getProperties().safelen; (void)tblgen_safelen;
|
|
auto tblgen_simdlen = getProperties().simdlen; (void)tblgen_simdlen;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps10(*this, tblgen_alignments, "alignments")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps11(*this, tblgen_linear_var_types, "linear_var_types")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps11(*this, tblgen_linear_modifiers, "linear_modifiers")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps12(*this, tblgen_order, "order")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps13(*this, tblgen_order_mod, "order_mod")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_private_syms, "private_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_private_needs_barrier, "private_needs_barrier")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps19(*this, tblgen_reduction_mod, "reduction_mod")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(*this, tblgen_reduction_byref, "reduction_byref")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_reduction_syms, "reduction_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps2(*this, tblgen_safelen, "safelen")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps2(*this, tblgen_simdlen, "simdlen")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*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_OpenMPOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps12(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup4 = getODSOperands(4);
|
|
|
|
for (auto v : valueGroup4) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup5 = getODSOperands(5);
|
|
|
|
for (auto v : valueGroup5) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup6 = getODSOperands(6);
|
|
|
|
for (auto v : valueGroup6) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*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_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SimdOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult SimdOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> aligned_varsOperands;
|
|
::llvm::SMLoc aligned_varsOperandsLoc;
|
|
(void)aligned_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> aligned_varsTypes;
|
|
::mlir::ArrayAttr alignmentsAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> if_exprOperands;
|
|
::llvm::SMLoc if_exprOperandsLoc;
|
|
(void)if_exprOperandsLoc;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> linear_varsOperands;
|
|
::llvm::SMLoc linear_varsOperandsLoc;
|
|
(void)linear_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> linear_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> linear_step_varsOperands;
|
|
::llvm::SMLoc linear_step_varsOperandsLoc;
|
|
(void)linear_step_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> linear_step_varsTypes;
|
|
::mlir::ArrayAttr linear_modifiersAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> nontemporal_varsOperands;
|
|
::llvm::SMLoc nontemporal_varsOperandsLoc;
|
|
(void)nontemporal_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> nontemporal_varsTypes;
|
|
::mlir::omp::ClauseOrderKindAttr orderAttr;
|
|
::mlir::omp::OrderModifierAttr order_modAttr;
|
|
::mlir::IntegerAttr safelenAttr;
|
|
::mlir::IntegerAttr simdlenAttr;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> private_varsOperands;
|
|
::llvm::SMLoc private_varsOperandsLoc;
|
|
(void)private_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> private_varsTypes;
|
|
::mlir::ArrayAttr private_symsAttr;
|
|
::mlir::UnitAttr private_needs_barrierAttr;
|
|
::mlir::omp::ReductionModifierAttr reduction_modAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> reduction_varsOperands;
|
|
::llvm::SMLoc reduction_varsOperandsLoc;
|
|
(void)reduction_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> reduction_varsTypes;
|
|
::mlir::DenseBoolArrayAttr reduction_byrefAttr;
|
|
::mlir::ArrayAttr reduction_symsAttr;
|
|
bool alignedClause = false;
|
|
bool ifClause = false;
|
|
bool linearClause = false;
|
|
bool nontemporalClause = false;
|
|
bool orderClause = false;
|
|
bool safelenClause = false;
|
|
bool simdlenClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("aligned"))) {
|
|
|
|
if (alignedClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`aligned` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
alignedClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
aligned_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseAlignedClause(parser, aligned_varsOperands, aligned_varsTypes, alignmentsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (alignmentsAttr)
|
|
result.getOrAddProperties<SimdOp::Properties>().alignments = alignmentsAttr;
|
|
}
|
|
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();
|
|
|
|
{
|
|
if_exprOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
if_exprOperands.push_back(operand);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("linear"))) {
|
|
|
|
if (linearClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`linear` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
linearClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
linear_varsOperandsLoc = parser.getCurrentLocation();
|
|
linear_step_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseLinearClause(parser, linear_varsOperands, linear_varsTypes, linear_step_varsOperands, linear_step_varsTypes, linear_modifiersAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (linear_modifiersAttr)
|
|
result.getOrAddProperties<SimdOp::Properties>().linear_modifiers = linear_modifiersAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("nontemporal"))) {
|
|
|
|
if (nontemporalClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`nontemporal` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
nontemporalClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
nontemporal_varsOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(nontemporal_varsOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(nontemporal_varsTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("order"))) {
|
|
|
|
if (orderClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`order` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
orderClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseOrderClause(parser, orderAttr, order_modAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (orderAttr)
|
|
result.getOrAddProperties<SimdOp::Properties>().order = orderAttr;
|
|
if (order_modAttr)
|
|
result.getOrAddProperties<SimdOp::Properties>().order_mod = order_modAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("safelen"))) {
|
|
|
|
if (safelenClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`safelen` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
safelenClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
::mlir::OptionalParseResult parseResultsafelenAttr =
|
|
parser.parseOptionalAttribute(safelenAttr, parser.getBuilder().getIntegerType(64));
|
|
if (parseResultsafelenAttr.has_value() && failed(*parseResultsafelenAttr))
|
|
return ::mlir::failure();
|
|
if (parseResultsafelenAttr.has_value() && succeeded(*parseResultsafelenAttr))
|
|
if (safelenAttr) result.getOrAddProperties<SimdOp::Properties>().safelen = safelenAttr;
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("simdlen"))) {
|
|
|
|
if (simdlenClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`simdlen` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
simdlenClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
::mlir::OptionalParseResult parseResultsimdlenAttr =
|
|
parser.parseOptionalAttribute(simdlenAttr, parser.getBuilder().getIntegerType(64));
|
|
if (parseResultsimdlenAttr.has_value() && failed(*parseResultsimdlenAttr))
|
|
return ::mlir::failure();
|
|
if (parseResultsimdlenAttr.has_value() && succeeded(*parseResultsimdlenAttr))
|
|
if (simdlenAttr) result.getOrAddProperties<SimdOp::Properties>().simdlen = simdlenAttr;
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
{
|
|
private_varsOperandsLoc = parser.getCurrentLocation();
|
|
reduction_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parsePrivateReductionRegion(parser, *regionRegion, private_varsOperands, private_varsTypes, private_symsAttr, private_needs_barrierAttr, reduction_modAttr, reduction_varsOperands, reduction_varsTypes, reduction_byrefAttr, reduction_symsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (private_symsAttr)
|
|
result.getOrAddProperties<SimdOp::Properties>().private_syms = private_symsAttr;
|
|
if (private_needs_barrierAttr)
|
|
result.getOrAddProperties<SimdOp::Properties>().private_needs_barrier = private_needs_barrierAttr;
|
|
if (reduction_modAttr)
|
|
result.getOrAddProperties<SimdOp::Properties>().reduction_mod = reduction_modAttr;
|
|
if (reduction_byrefAttr)
|
|
result.getOrAddProperties<SimdOp::Properties>().reduction_byref = reduction_byrefAttr;
|
|
if (reduction_symsAttr)
|
|
result.getOrAddProperties<SimdOp::Properties>().reduction_syms = reduction_symsAttr;
|
|
}
|
|
{
|
|
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<int32_t>({static_cast<int32_t>(aligned_varsOperands.size()), static_cast<int32_t>(if_exprOperands.size()), static_cast<int32_t>(linear_varsOperands.size()), static_cast<int32_t>(linear_step_varsOperands.size()), static_cast<int32_t>(nontemporal_varsOperands.size()), static_cast<int32_t>(private_varsOperands.size()), static_cast<int32_t>(reduction_varsOperands.size())}), result.getOrAddProperties<SimdOp::Properties>().operandSegmentSizes.begin());
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1);
|
|
if (parser.resolveOperands(aligned_varsOperands, aligned_varsTypes, aligned_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!if_exprOperands.empty()) {
|
|
if (parser.resolveOperands(if_exprOperands, odsBuildableType0, if_exprOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(linear_varsOperands, linear_varsTypes, linear_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(linear_step_varsOperands, linear_step_varsTypes, linear_step_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(nontemporal_varsOperands, nontemporal_varsTypes, nontemporal_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(private_varsOperands, private_varsTypes, private_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(reduction_varsOperands, reduction_varsTypes, reduction_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SimdOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getAlignedVars().size() || (getAlignmentsAttr())) {
|
|
_odsPrinter << ' ' << "aligned";
|
|
_odsPrinter << "(";
|
|
printAlignedClause(_odsPrinter, *this, getAlignedVars(), getAlignedVars().getTypes(), getAlignmentsAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getIfExpr()) {
|
|
_odsPrinter << ' ' << "if";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getIfExpr())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getLinearVars().size() || getLinearStepVars().size() || (getLinearModifiersAttr())) {
|
|
_odsPrinter << ' ' << "linear";
|
|
_odsPrinter << "(";
|
|
printLinearClause(_odsPrinter, *this, getLinearVars(), getLinearVars().getTypes(), getLinearStepVars(), getLinearStepVars().getTypes(), getLinearModifiersAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getNontemporalVars().size()) {
|
|
_odsPrinter << ' ' << "nontemporal";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getNontemporalVars();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getNontemporalVars().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getOrderAttr()) || (getOrderModAttr())) {
|
|
_odsPrinter << ' ' << "order";
|
|
_odsPrinter << "(";
|
|
printOrderClause(_odsPrinter, *this, getOrderAttr(), getOrderModAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getSafelenAttr())) {
|
|
_odsPrinter << ' ' << "safelen";
|
|
_odsPrinter << "(";
|
|
_odsPrinter.printAttributeWithoutType(getSafelenAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getSimdlenAttr())) {
|
|
_odsPrinter << ' ' << "simdlen";
|
|
_odsPrinter << "(";
|
|
_odsPrinter.printAttributeWithoutType(getSimdlenAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ';
|
|
printPrivateReductionRegion(_odsPrinter, *this, getRegion(), getPrivateVars(), getPrivateVars().getTypes(), getPrivateSymsAttr(), getPrivateNeedsBarrierAttr(), getReductionModAttr(), getReductionVars(), getReductionVars().getTypes(), getReductionByrefAttr(), getReductionSymsAttr());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("alignments");
|
|
elidedAttrs.push_back("linear_modifiers");
|
|
elidedAttrs.push_back("order");
|
|
elidedAttrs.push_back("order_mod");
|
|
elidedAttrs.push_back("safelen");
|
|
elidedAttrs.push_back("simdlen");
|
|
elidedAttrs.push_back("private_syms");
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
elidedAttrs.push_back("reduction_mod");
|
|
elidedAttrs.push_back("reduction_byref");
|
|
elidedAttrs.push_back("reduction_syms");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getPrivateNeedsBarrierAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::SimdOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::SimdOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::SingleOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
SingleOpGenericAdaptorBase::SingleOpGenericAdaptorBase(SingleOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> SingleOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SingleOpGenericAdaptorBase::getCopyprivateSyms() {
|
|
auto attr = getCopyprivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr SingleOpGenericAdaptorBase::getNowaitAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nowait);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool SingleOpGenericAdaptorBase::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SingleOpGenericAdaptorBase::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr SingleOpGenericAdaptorBase::getPrivateNeedsBarrierAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().private_needs_barrier);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool SingleOpGenericAdaptorBase::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
SingleOpAdaptor::SingleOpAdaptor(SingleOp op) : SingleOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult SingleOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_copyprivate_syms = getProperties().copyprivate_syms; (void)tblgen_copyprivate_syms;
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
|
|
if (tblgen_copyprivate_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_copyprivate_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_copyprivate_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.single' op attribute 'copyprivate_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_nowait && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nowait))))
|
|
return emitError(loc, "'omp.single' op attribute 'nowait' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_private_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_private_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_private_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.single' op attribute 'private_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_private_needs_barrier && !((::llvm::isa<::mlir::UnitAttr>(tblgen_private_needs_barrier))))
|
|
return emitError(loc, "'omp.single' op attribute 'private_needs_barrier' failed to satisfy constraint: unit attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> SingleOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange SingleOp::getAllocateVarsMutable() {
|
|
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 SingleOp::getAllocatorVarsMutable() {
|
|
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 SingleOp::getCopyprivateVarsMutable() {
|
|
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 SingleOp::getPrivateVarsMutable() {
|
|
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 SingleOp::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.copyprivate_syms;
|
|
auto attr = dict.get("copyprivate_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `copyprivate_syms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.nowait;
|
|
auto attr = dict.get("nowait");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nowait` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_needs_barrier;
|
|
auto attr = dict.get("private_needs_barrier");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_needs_barrier` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_syms;
|
|
auto attr = dict.get("private_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_syms` 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 SingleOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.copyprivate_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("copyprivate_syms",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.nowait;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nowait",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_needs_barrier;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_needs_barrier",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_syms",
|
|
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 SingleOp::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.copyprivate_syms.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.nowait.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_needs_barrier.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_syms.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> SingleOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "copyprivate_syms")
|
|
return prop.copyprivate_syms;
|
|
|
|
if (name == "nowait")
|
|
return prop.nowait;
|
|
|
|
if (name == "private_needs_barrier")
|
|
return prop.private_needs_barrier;
|
|
|
|
if (name == "private_syms")
|
|
return prop.private_syms;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void SingleOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "copyprivate_syms") {
|
|
prop.copyprivate_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.copyprivate_syms)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "nowait") {
|
|
prop.nowait = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nowait)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_needs_barrier") {
|
|
prop.private_needs_barrier = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_needs_barrier)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_syms") {
|
|
prop.private_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_syms)>>(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 SingleOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.copyprivate_syms) attrs.append("copyprivate_syms", prop.copyprivate_syms);
|
|
|
|
if (prop.nowait) attrs.append("nowait", prop.nowait);
|
|
|
|
if (prop.private_needs_barrier) attrs.append("private_needs_barrier", prop.private_needs_barrier);
|
|
|
|
if (prop.private_syms) attrs.append("private_syms", prop.private_syms);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult SingleOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getCopyprivateSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "copyprivate_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNowaitAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "nowait", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateNeedsBarrierAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "private_needs_barrier", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "private_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SingleOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.copyprivate_syms)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nowait)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_needs_barrier)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_syms)))
|
|
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 SingleOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.copyprivate_syms);
|
|
|
|
writer.writeOptionalAttribute(prop.nowait);
|
|
|
|
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
|
|
}
|
|
|
|
writer.writeOptionalAttribute(prop.private_needs_barrier);
|
|
|
|
writer.writeOptionalAttribute(prop.private_syms);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SingleOp::getCopyprivateSyms() {
|
|
auto attr = getCopyprivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool SingleOp::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > SingleOp::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool SingleOp::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
void SingleOp::setNowait(bool attrValue) {
|
|
auto &odsProp = getProperties().nowait;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void SingleOp::setPrivateNeedsBarrier(bool attrValue) {
|
|
auto &odsProp = getProperties().private_needs_barrier;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
SingleOp SingleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const SingleOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<SingleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SingleOp SingleOp::create(::mlir::ImplicitLocOpBuilder &builder, const SingleOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void SingleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange copyprivate_vars, /*optional*/::mlir::ArrayAttr copyprivate_syms, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(copyprivate_vars);
|
|
odsState.addOperands(private_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(copyprivate_vars.size()), static_cast<int32_t>(private_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (copyprivate_syms) {
|
|
odsState.getOrAddProperties<Properties>().copyprivate_syms = copyprivate_syms;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
SingleOp SingleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange copyprivate_vars, /*optional*/::mlir::ArrayAttr copyprivate_syms, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(copyprivate_vars)>(copyprivate_vars), std::forward<decltype(copyprivate_syms)>(copyprivate_syms), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier));
|
|
auto __res__ = ::llvm::dyn_cast<SingleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SingleOp SingleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange copyprivate_vars, /*optional*/::mlir::ArrayAttr copyprivate_syms, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(copyprivate_vars)>(copyprivate_vars), std::forward<decltype(copyprivate_syms)>(copyprivate_syms), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier));
|
|
}
|
|
|
|
void SingleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange copyprivate_vars, /*optional*/::mlir::ArrayAttr copyprivate_syms, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(copyprivate_vars);
|
|
odsState.addOperands(private_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(copyprivate_vars.size()), static_cast<int32_t>(private_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (copyprivate_syms) {
|
|
odsState.getOrAddProperties<Properties>().copyprivate_syms = copyprivate_syms;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SingleOp SingleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange copyprivate_vars, /*optional*/::mlir::ArrayAttr copyprivate_syms, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(copyprivate_vars)>(copyprivate_vars), std::forward<decltype(copyprivate_syms)>(copyprivate_syms), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier));
|
|
auto __res__ = ::llvm::dyn_cast<SingleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SingleOp SingleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange copyprivate_vars, /*optional*/::mlir::ArrayAttr copyprivate_syms, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(copyprivate_vars)>(copyprivate_vars), std::forward<decltype(copyprivate_syms)>(copyprivate_syms), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier));
|
|
}
|
|
|
|
void SingleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange copyprivate_vars, /*optional*/::mlir::ArrayAttr copyprivate_syms, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(copyprivate_vars);
|
|
odsState.addOperands(private_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(copyprivate_vars.size()), static_cast<int32_t>(private_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (copyprivate_syms) {
|
|
odsState.getOrAddProperties<Properties>().copyprivate_syms = copyprivate_syms;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
SingleOp SingleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange copyprivate_vars, /*optional*/::mlir::ArrayAttr copyprivate_syms, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(copyprivate_vars)>(copyprivate_vars), std::forward<decltype(copyprivate_syms)>(copyprivate_syms), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier));
|
|
auto __res__ = ::llvm::dyn_cast<SingleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SingleOp SingleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange copyprivate_vars, /*optional*/::mlir::ArrayAttr copyprivate_syms, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(copyprivate_vars)>(copyprivate_vars), std::forward<decltype(copyprivate_syms)>(copyprivate_syms), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier));
|
|
}
|
|
|
|
void SingleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange copyprivate_vars, /*optional*/::mlir::ArrayAttr copyprivate_syms, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(copyprivate_vars);
|
|
odsState.addOperands(private_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(copyprivate_vars.size()), static_cast<int32_t>(private_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (copyprivate_syms) {
|
|
odsState.getOrAddProperties<Properties>().copyprivate_syms = copyprivate_syms;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SingleOp SingleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange copyprivate_vars, /*optional*/::mlir::ArrayAttr copyprivate_syms, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(copyprivate_vars)>(copyprivate_vars), std::forward<decltype(copyprivate_syms)>(copyprivate_syms), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier));
|
|
auto __res__ = ::llvm::dyn_cast<SingleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SingleOp SingleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange copyprivate_vars, /*optional*/::mlir::ArrayAttr copyprivate_syms, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(copyprivate_vars)>(copyprivate_vars), std::forward<decltype(copyprivate_syms)>(copyprivate_syms), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier));
|
|
}
|
|
|
|
void SingleOp::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<SingleOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
SingleOp SingleOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<SingleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SingleOp SingleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void SingleOp::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&>(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);
|
|
}
|
|
|
|
SingleOp SingleOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<SingleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SingleOp SingleOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult SingleOp::verifyInvariantsImpl() {
|
|
auto tblgen_copyprivate_syms = getProperties().copyprivate_syms; (void)tblgen_copyprivate_syms;
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_copyprivate_syms, "copyprivate_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_nowait, "nowait")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_private_syms, "private_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_private_needs_barrier, "private_needs_barrier")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*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_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SingleOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult SingleOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocate_varsOperands;
|
|
::llvm::SMLoc allocate_varsOperandsLoc;
|
|
(void)allocate_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocate_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocator_varsOperands;
|
|
::llvm::SMLoc allocator_varsOperandsLoc;
|
|
(void)allocator_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocator_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> copyprivate_varsOperands;
|
|
::llvm::SMLoc copyprivate_varsOperandsLoc;
|
|
(void)copyprivate_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> copyprivate_varsTypes;
|
|
::mlir::ArrayAttr copyprivate_symsAttr;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> private_varsOperands;
|
|
::llvm::SMLoc private_varsOperandsLoc;
|
|
(void)private_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> private_varsTypes;
|
|
::mlir::ArrayAttr private_symsAttr;
|
|
::mlir::UnitAttr private_needs_barrierAttr;
|
|
bool allocateClause = false;
|
|
bool copyprivateClause = false;
|
|
bool nowaitClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("allocate"))) {
|
|
|
|
if (allocateClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`allocate` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
allocateClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
allocate_varsOperandsLoc = parser.getCurrentLocation();
|
|
allocator_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseAllocateAndAllocator(parser, allocate_varsOperands, allocate_varsTypes, allocator_varsOperands, allocator_varsTypes);
|
|
if (odsResult) return ::mlir::failure();
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("copyprivate"))) {
|
|
|
|
if (copyprivateClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`copyprivate` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
copyprivateClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
copyprivate_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseCopyprivate(parser, copyprivate_varsOperands, copyprivate_varsTypes, copyprivate_symsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (copyprivate_symsAttr)
|
|
result.getOrAddProperties<SingleOp::Properties>().copyprivate_syms = copyprivate_symsAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("nowait"))) {
|
|
|
|
if (nowaitClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`nowait` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
nowaitClause = true;
|
|
result.getOrAddProperties<SingleOp::Properties>().nowait = parser.getBuilder().getUnitAttr(); } else {
|
|
break;
|
|
}
|
|
}
|
|
{
|
|
private_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parsePrivateRegion(parser, *regionRegion, private_varsOperands, private_varsTypes, private_symsAttr, private_needs_barrierAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (private_symsAttr)
|
|
result.getOrAddProperties<SingleOp::Properties>().private_syms = private_symsAttr;
|
|
if (private_needs_barrierAttr)
|
|
result.getOrAddProperties<SingleOp::Properties>().private_needs_barrier = private_needs_barrierAttr;
|
|
}
|
|
{
|
|
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<int32_t>({static_cast<int32_t>(allocate_varsOperands.size()), static_cast<int32_t>(allocator_varsOperands.size()), static_cast<int32_t>(copyprivate_varsOperands.size()), static_cast<int32_t>(private_varsOperands.size())}), result.getOrAddProperties<SingleOp::Properties>().operandSegmentSizes.begin());
|
|
if (parser.resolveOperands(allocate_varsOperands, allocate_varsTypes, allocate_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(allocator_varsOperands, allocator_varsTypes, allocator_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(copyprivate_varsOperands, copyprivate_varsTypes, copyprivate_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(private_varsOperands, private_varsTypes, private_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SingleOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getAllocateVars().size() || getAllocatorVars().size()) {
|
|
_odsPrinter << ' ' << "allocate";
|
|
_odsPrinter << "(";
|
|
printAllocateAndAllocator(_odsPrinter, *this, getAllocateVars(), getAllocateVars().getTypes(), getAllocatorVars(), getAllocatorVars().getTypes());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getCopyprivateVars().size() || (getCopyprivateSymsAttr())) {
|
|
_odsPrinter << ' ' << "copyprivate";
|
|
_odsPrinter << "(";
|
|
printCopyprivate(_odsPrinter, *this, getCopyprivateVars(), getCopyprivateVars().getTypes(), getCopyprivateSymsAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getNowaitAttr() && getNowaitAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "nowait";
|
|
}
|
|
_odsPrinter << ' ';
|
|
printPrivateRegion(_odsPrinter, *this, getRegion(), getPrivateVars(), getPrivateVars().getTypes(), getPrivateSymsAttr(), getPrivateNeedsBarrierAttr());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("copyprivate_syms");
|
|
elidedAttrs.push_back("nowait");
|
|
elidedAttrs.push_back("private_syms");
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getNowaitAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("nowait");
|
|
}
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getPrivateNeedsBarrierAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::SingleOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::SingleOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::TargetAllocMemOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TargetAllocMemOpGenericAdaptorBase::TargetAllocMemOpGenericAdaptorBase(TargetAllocMemOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> TargetAllocMemOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::Type TargetAllocMemOpGenericAdaptorBase::getInType() {
|
|
auto attr = getInTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::std::optional< ::llvm::StringRef > TargetAllocMemOpGenericAdaptorBase::getUniqName() {
|
|
auto attr = getUniqNameAttr();
|
|
return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::llvm::StringRef > TargetAllocMemOpGenericAdaptorBase::getBindcName() {
|
|
auto attr = getBindcNameAttr();
|
|
return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
TargetAllocMemOpAdaptor::TargetAllocMemOpAdaptor(TargetAllocMemOp op) : TargetAllocMemOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TargetAllocMemOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_bindc_name = getProperties().bindc_name; (void)tblgen_bindc_name;
|
|
auto tblgen_in_type = getProperties().in_type; (void)tblgen_in_type;
|
|
if (!tblgen_in_type) return emitError(loc, "'omp.target_allocmem' op requires attribute 'in_type'");
|
|
auto tblgen_uniq_name = getProperties().uniq_name; (void)tblgen_uniq_name;
|
|
|
|
if (tblgen_in_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_in_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_in_type).getValue()))) && ((true))))
|
|
return emitError(loc, "'omp.target_allocmem' op attribute 'in_type' failed to satisfy constraint: any type attribute");
|
|
|
|
if (tblgen_uniq_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_uniq_name))))
|
|
return emitError(loc, "'omp.target_allocmem' op attribute 'uniq_name' failed to satisfy constraint: string attribute");
|
|
|
|
if (tblgen_bindc_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_bindc_name))))
|
|
return emitError(loc, "'omp.target_allocmem' op attribute 'bindc_name' failed to satisfy constraint: string attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> TargetAllocMemOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange TargetAllocMemOp::getTypeparamsMutable() {
|
|
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 TargetAllocMemOp::getShapeMutable() {
|
|
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 TargetAllocMemOp::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.bindc_name;
|
|
auto attr = dict.get("bindc_name");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `bindc_name` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.in_type;
|
|
auto attr = dict.get("in_type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `in_type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.uniq_name;
|
|
auto attr = dict.get("uniq_name");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `uniq_name` 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 TargetAllocMemOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.bindc_name;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("bindc_name",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.in_type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("in_type",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.uniq_name;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("uniq_name",
|
|
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 TargetAllocMemOp::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.bindc_name.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.in_type.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.uniq_name.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TargetAllocMemOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "bindc_name")
|
|
return prop.bindc_name;
|
|
|
|
if (name == "in_type")
|
|
return prop.in_type;
|
|
|
|
if (name == "uniq_name")
|
|
return prop.uniq_name;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TargetAllocMemOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "bindc_name") {
|
|
prop.bindc_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.bindc_name)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "in_type") {
|
|
prop.in_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.in_type)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "uniq_name") {
|
|
prop.uniq_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.uniq_name)>>(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 TargetAllocMemOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.bindc_name) attrs.append("bindc_name", prop.bindc_name);
|
|
|
|
if (prop.in_type) attrs.append("in_type", prop.in_type);
|
|
|
|
if (prop.uniq_name) attrs.append("uniq_name", prop.uniq_name);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult TargetAllocMemOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getBindcNameAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps8(attr, "bindc_name", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getInTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(attr, "in_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getUniqNameAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps8(attr, "uniq_name", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TargetAllocMemOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.bindc_name)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.in_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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.uniq_name)))
|
|
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 TargetAllocMemOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.bindc_name);
|
|
writer.writeAttribute(prop.in_type);
|
|
|
|
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
|
|
}
|
|
|
|
writer.writeOptionalAttribute(prop.uniq_name);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
::mlir::Type TargetAllocMemOp::getInType() {
|
|
auto attr = getInTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::std::optional< ::llvm::StringRef > TargetAllocMemOp::getUniqName() {
|
|
auto attr = getUniqNameAttr();
|
|
return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::llvm::StringRef > TargetAllocMemOp::getBindcName() {
|
|
auto attr = getBindcNameAttr();
|
|
return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
void TargetAllocMemOp::setInType(::mlir::Type attrValue) {
|
|
getProperties().in_type = ::mlir::TypeAttr::get(attrValue);
|
|
}
|
|
|
|
void TargetAllocMemOp::setUniqName(::std::optional<::llvm::StringRef> attrValue) {
|
|
auto &odsProp = getProperties().uniq_name;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TargetAllocMemOp::setBindcName(::std::optional<::llvm::StringRef> attrValue) {
|
|
auto &odsProp = getProperties().bindc_name;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TargetAllocMemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value device, ::mlir::TypeAttr in_type, /*optional*/::mlir::StringAttr uniq_name, /*optional*/::mlir::StringAttr bindc_name, ::mlir::ValueRange typeparams, ::mlir::ValueRange shape) {
|
|
odsState.addOperands(device);
|
|
odsState.addOperands(typeparams);
|
|
odsState.addOperands(shape);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({1, static_cast<int32_t>(typeparams.size()), static_cast<int32_t>(shape.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
odsState.getOrAddProperties<Properties>().in_type = in_type;
|
|
if (uniq_name) {
|
|
odsState.getOrAddProperties<Properties>().uniq_name = uniq_name;
|
|
}
|
|
if (bindc_name) {
|
|
odsState.getOrAddProperties<Properties>().bindc_name = bindc_name;
|
|
}
|
|
odsState.addTypes(resultType0);
|
|
}
|
|
|
|
TargetAllocMemOp TargetAllocMemOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type resultType0, ::mlir::Value device, ::mlir::TypeAttr in_type, /*optional*/::mlir::StringAttr uniq_name, /*optional*/::mlir::StringAttr bindc_name, ::mlir::ValueRange typeparams, ::mlir::ValueRange shape) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultType0)>(resultType0), std::forward<decltype(device)>(device), std::forward<decltype(in_type)>(in_type), std::forward<decltype(uniq_name)>(uniq_name), std::forward<decltype(bindc_name)>(bindc_name), std::forward<decltype(typeparams)>(typeparams), std::forward<decltype(shape)>(shape));
|
|
auto __res__ = ::llvm::dyn_cast<TargetAllocMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetAllocMemOp TargetAllocMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type resultType0, ::mlir::Value device, ::mlir::TypeAttr in_type, /*optional*/::mlir::StringAttr uniq_name, /*optional*/::mlir::StringAttr bindc_name, ::mlir::ValueRange typeparams, ::mlir::ValueRange shape) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultType0)>(resultType0), std::forward<decltype(device)>(device), std::forward<decltype(in_type)>(in_type), std::forward<decltype(uniq_name)>(uniq_name), std::forward<decltype(bindc_name)>(bindc_name), std::forward<decltype(typeparams)>(typeparams), std::forward<decltype(shape)>(shape));
|
|
}
|
|
|
|
void TargetAllocMemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value device, ::mlir::TypeAttr in_type, /*optional*/::mlir::StringAttr uniq_name, /*optional*/::mlir::StringAttr bindc_name, ::mlir::ValueRange typeparams, ::mlir::ValueRange shape) {
|
|
odsState.addOperands(device);
|
|
odsState.addOperands(typeparams);
|
|
odsState.addOperands(shape);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({1, static_cast<int32_t>(typeparams.size()), static_cast<int32_t>(shape.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
odsState.getOrAddProperties<Properties>().in_type = in_type;
|
|
if (uniq_name) {
|
|
odsState.getOrAddProperties<Properties>().uniq_name = uniq_name;
|
|
}
|
|
if (bindc_name) {
|
|
odsState.getOrAddProperties<Properties>().bindc_name = bindc_name;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetAllocMemOp TargetAllocMemOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value device, ::mlir::TypeAttr in_type, /*optional*/::mlir::StringAttr uniq_name, /*optional*/::mlir::StringAttr bindc_name, ::mlir::ValueRange typeparams, ::mlir::ValueRange shape) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(device)>(device), std::forward<decltype(in_type)>(in_type), std::forward<decltype(uniq_name)>(uniq_name), std::forward<decltype(bindc_name)>(bindc_name), std::forward<decltype(typeparams)>(typeparams), std::forward<decltype(shape)>(shape));
|
|
auto __res__ = ::llvm::dyn_cast<TargetAllocMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetAllocMemOp TargetAllocMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value device, ::mlir::TypeAttr in_type, /*optional*/::mlir::StringAttr uniq_name, /*optional*/::mlir::StringAttr bindc_name, ::mlir::ValueRange typeparams, ::mlir::ValueRange shape) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(device)>(device), std::forward<decltype(in_type)>(in_type), std::forward<decltype(uniq_name)>(uniq_name), std::forward<decltype(bindc_name)>(bindc_name), std::forward<decltype(typeparams)>(typeparams), std::forward<decltype(shape)>(shape));
|
|
}
|
|
|
|
void TargetAllocMemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value device, ::mlir::Type in_type, /*optional*/::mlir::StringAttr uniq_name, /*optional*/::mlir::StringAttr bindc_name, ::mlir::ValueRange typeparams, ::mlir::ValueRange shape) {
|
|
odsState.addOperands(device);
|
|
odsState.addOperands(typeparams);
|
|
odsState.addOperands(shape);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({1, static_cast<int32_t>(typeparams.size()), static_cast<int32_t>(shape.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
odsState.getOrAddProperties<Properties>().in_type = ::mlir::TypeAttr::get(in_type);
|
|
if (uniq_name) {
|
|
odsState.getOrAddProperties<Properties>().uniq_name = uniq_name;
|
|
}
|
|
if (bindc_name) {
|
|
odsState.getOrAddProperties<Properties>().bindc_name = bindc_name;
|
|
}
|
|
odsState.addTypes(resultType0);
|
|
}
|
|
|
|
TargetAllocMemOp TargetAllocMemOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type resultType0, ::mlir::Value device, ::mlir::Type in_type, /*optional*/::mlir::StringAttr uniq_name, /*optional*/::mlir::StringAttr bindc_name, ::mlir::ValueRange typeparams, ::mlir::ValueRange shape) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultType0)>(resultType0), std::forward<decltype(device)>(device), std::forward<decltype(in_type)>(in_type), std::forward<decltype(uniq_name)>(uniq_name), std::forward<decltype(bindc_name)>(bindc_name), std::forward<decltype(typeparams)>(typeparams), std::forward<decltype(shape)>(shape));
|
|
auto __res__ = ::llvm::dyn_cast<TargetAllocMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetAllocMemOp TargetAllocMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type resultType0, ::mlir::Value device, ::mlir::Type in_type, /*optional*/::mlir::StringAttr uniq_name, /*optional*/::mlir::StringAttr bindc_name, ::mlir::ValueRange typeparams, ::mlir::ValueRange shape) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultType0)>(resultType0), std::forward<decltype(device)>(device), std::forward<decltype(in_type)>(in_type), std::forward<decltype(uniq_name)>(uniq_name), std::forward<decltype(bindc_name)>(bindc_name), std::forward<decltype(typeparams)>(typeparams), std::forward<decltype(shape)>(shape));
|
|
}
|
|
|
|
void TargetAllocMemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value device, ::mlir::Type in_type, /*optional*/::mlir::StringAttr uniq_name, /*optional*/::mlir::StringAttr bindc_name, ::mlir::ValueRange typeparams, ::mlir::ValueRange shape) {
|
|
odsState.addOperands(device);
|
|
odsState.addOperands(typeparams);
|
|
odsState.addOperands(shape);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({1, static_cast<int32_t>(typeparams.size()), static_cast<int32_t>(shape.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
odsState.getOrAddProperties<Properties>().in_type = ::mlir::TypeAttr::get(in_type);
|
|
if (uniq_name) {
|
|
odsState.getOrAddProperties<Properties>().uniq_name = uniq_name;
|
|
}
|
|
if (bindc_name) {
|
|
odsState.getOrAddProperties<Properties>().bindc_name = bindc_name;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetAllocMemOp TargetAllocMemOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value device, ::mlir::Type in_type, /*optional*/::mlir::StringAttr uniq_name, /*optional*/::mlir::StringAttr bindc_name, ::mlir::ValueRange typeparams, ::mlir::ValueRange shape) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(device)>(device), std::forward<decltype(in_type)>(in_type), std::forward<decltype(uniq_name)>(uniq_name), std::forward<decltype(bindc_name)>(bindc_name), std::forward<decltype(typeparams)>(typeparams), std::forward<decltype(shape)>(shape));
|
|
auto __res__ = ::llvm::dyn_cast<TargetAllocMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetAllocMemOp TargetAllocMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value device, ::mlir::Type in_type, /*optional*/::mlir::StringAttr uniq_name, /*optional*/::mlir::StringAttr bindc_name, ::mlir::ValueRange typeparams, ::mlir::ValueRange shape) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(device)>(device), std::forward<decltype(in_type)>(in_type), std::forward<decltype(uniq_name)>(uniq_name), std::forward<decltype(bindc_name)>(bindc_name), std::forward<decltype(typeparams)>(typeparams), std::forward<decltype(shape)>(shape));
|
|
}
|
|
|
|
void TargetAllocMemOp::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<TargetAllocMemOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
TargetAllocMemOp TargetAllocMemOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<TargetAllocMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetAllocMemOp TargetAllocMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void TargetAllocMemOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetAllocMemOp TargetAllocMemOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<TargetAllocMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetAllocMemOp TargetAllocMemOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult TargetAllocMemOp::verifyInvariantsImpl() {
|
|
auto tblgen_bindc_name = getProperties().bindc_name; (void)tblgen_bindc_name;
|
|
auto tblgen_in_type = getProperties().in_type; (void)tblgen_in_type;
|
|
if (!tblgen_in_type) return emitOpError("requires attribute 'in_type'");
|
|
auto tblgen_uniq_name = getProperties().uniq_name; (void)tblgen_uniq_name;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps1(*this, tblgen_in_type, "in_type")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps8(*this, tblgen_uniq_name, "uniq_name")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps8(*this, tblgen_bindc_name, "bindc_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_OpenMPOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps14(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps14(*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_OpenMPOps18(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TargetAllocMemOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult TargetAllocMemOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::OpAsmParser::UnresolvedOperand deviceRawOperand{};
|
|
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> deviceOperands(&deviceRawOperand, 1); ::llvm::SMLoc deviceOperandsLoc;
|
|
(void)deviceOperandsLoc;
|
|
::mlir::Type deviceRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> deviceTypes(&deviceRawType, 1);
|
|
::mlir::TypeAttr in_typeAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> typeparamsOperands;
|
|
::llvm::SMLoc typeparamsOperandsLoc;
|
|
(void)typeparamsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> typeparamsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> shapeOperands;
|
|
::llvm::SMLoc shapeOperandsLoc;
|
|
(void)shapeOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> shapeTypes;
|
|
|
|
deviceOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperand(deviceRawOperand))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
::mlir::IntegerType type;
|
|
if (parser.parseCustomTypeWithFallback(type))
|
|
return ::mlir::failure();
|
|
deviceRawType = type;
|
|
}
|
|
if (parser.parseComma())
|
|
return ::mlir::failure();
|
|
{
|
|
typeparamsOperandsLoc = parser.getCurrentLocation();
|
|
shapeOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseHeapAllocClause(parser, in_typeAttr, typeparamsOperands, typeparamsTypes, shapeOperands, shapeTypes);
|
|
if (odsResult) return ::mlir::failure();
|
|
result.getOrAddProperties<TargetAllocMemOp::Properties>().in_type = in_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();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({1, static_cast<int32_t>(typeparamsOperands.size()), static_cast<int32_t>(shapeOperands.size())}), result.getOrAddProperties<TargetAllocMemOp::Properties>().operandSegmentSizes.begin());
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(64);
|
|
result.addTypes(odsBuildableType0);
|
|
if (parser.resolveOperands(deviceOperands, deviceTypes, deviceOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(typeparamsOperands, typeparamsTypes, typeparamsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(shapeOperands, shapeTypes, shapeOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TargetAllocMemOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getDevice();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
{
|
|
auto type = getDevice().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type))
|
|
_odsPrinter.printStrippedAttrOrType(validType);
|
|
else
|
|
_odsPrinter << type;
|
|
}
|
|
_odsPrinter << ",";
|
|
_odsPrinter << ' ';
|
|
printHeapAllocClause(_odsPrinter, *this, getInTypeAttr(), getTypeparams(), getTypeparams().getTypes(), getShape(), getShape().getTypes());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("in_type");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
void TargetAllocMemOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
effects.emplace_back(::mlir::MemoryEffects::Allocate::get(), 0, false, ::mlir::SideEffects::DefaultResource::get());
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::TargetAllocMemOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::TargetAllocMemOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::TargetDataOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TargetDataOpGenericAdaptorBase::TargetDataOpGenericAdaptorBase(TargetDataOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> TargetDataOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
TargetDataOpAdaptor::TargetDataOpAdaptor(TargetDataOp op) : TargetDataOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TargetDataOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> TargetDataOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange TargetDataOp::getDeviceMutable() {
|
|
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 TargetDataOp::getIfExprMutable() {
|
|
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 TargetDataOp::getMapVarsMutable() {
|
|
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 TargetDataOp::getMapIteratedMutable() {
|
|
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 TargetDataOp::getUseDeviceAddrVarsMutable() {
|
|
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 TargetDataOp::getUseDevicePtrVarsMutable() {
|
|
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;
|
|
}
|
|
|
|
::llvm::LogicalResult TargetDataOp::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 TargetDataOp::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 TargetDataOp::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<mlir::Attribute> TargetDataOp::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 TargetDataOp::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 TargetDataOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult TargetDataOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TargetDataOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(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 TargetDataOp::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));
|
|
;
|
|
}
|
|
}
|
|
|
|
TargetDataOp TargetDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const TargetDataOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<TargetDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetDataOp TargetDataOp::create(::mlir::ImplicitLocOpBuilder &builder, const TargetDataOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void TargetDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, ::mlir::ValueRange use_device_addr_vars, ::mlir::ValueRange use_device_ptr_vars) {
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
odsState.addOperands(use_device_addr_vars);
|
|
odsState.addOperands(use_device_ptr_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({(device ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size()), static_cast<int32_t>(use_device_addr_vars.size()), static_cast<int32_t>(use_device_ptr_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
TargetDataOp TargetDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, ::mlir::ValueRange use_device_addr_vars, ::mlir::ValueRange use_device_ptr_vars) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(use_device_addr_vars)>(use_device_addr_vars), std::forward<decltype(use_device_ptr_vars)>(use_device_ptr_vars));
|
|
auto __res__ = ::llvm::dyn_cast<TargetDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetDataOp TargetDataOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, ::mlir::ValueRange use_device_addr_vars, ::mlir::ValueRange use_device_ptr_vars) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(use_device_addr_vars)>(use_device_addr_vars), std::forward<decltype(use_device_ptr_vars)>(use_device_ptr_vars));
|
|
}
|
|
|
|
void TargetDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, ::mlir::ValueRange use_device_addr_vars, ::mlir::ValueRange use_device_ptr_vars) {
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
odsState.addOperands(use_device_addr_vars);
|
|
odsState.addOperands(use_device_ptr_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({(device ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size()), static_cast<int32_t>(use_device_addr_vars.size()), static_cast<int32_t>(use_device_ptr_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetDataOp TargetDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, ::mlir::ValueRange use_device_addr_vars, ::mlir::ValueRange use_device_ptr_vars) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(use_device_addr_vars)>(use_device_addr_vars), std::forward<decltype(use_device_ptr_vars)>(use_device_ptr_vars));
|
|
auto __res__ = ::llvm::dyn_cast<TargetDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetDataOp TargetDataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, ::mlir::ValueRange use_device_addr_vars, ::mlir::ValueRange use_device_ptr_vars) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(use_device_addr_vars)>(use_device_addr_vars), std::forward<decltype(use_device_ptr_vars)>(use_device_ptr_vars));
|
|
}
|
|
|
|
void TargetDataOp::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<TargetDataOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
TargetDataOp TargetDataOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<TargetDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetDataOp TargetDataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void TargetDataOp::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&>(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);
|
|
}
|
|
|
|
TargetDataOp TargetDataOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<TargetDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetDataOp TargetDataOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult TargetDataOp::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_OpenMPOps6(*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_OpenMPOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps11(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup4 = getODSOperands(4);
|
|
|
|
for (auto v : valueGroup4) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup5 = getODSOperands(5);
|
|
|
|
for (auto v : valueGroup5) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*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_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TargetDataOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult TargetDataOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> deviceOperands;
|
|
::llvm::SMLoc deviceOperandsLoc;
|
|
(void)deviceOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> deviceTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> if_exprOperands;
|
|
::llvm::SMLoc if_exprOperandsLoc;
|
|
(void)if_exprOperandsLoc;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> map_varsOperands;
|
|
::llvm::SMLoc map_varsOperandsLoc;
|
|
(void)map_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> map_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> map_iteratedOperands;
|
|
::llvm::SMLoc map_iteratedOperandsLoc;
|
|
(void)map_iteratedOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> map_iteratedTypes;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> use_device_addr_varsOperands;
|
|
::llvm::SMLoc use_device_addr_varsOperandsLoc;
|
|
(void)use_device_addr_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> use_device_addr_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> use_device_ptr_varsOperands;
|
|
::llvm::SMLoc use_device_ptr_varsOperandsLoc;
|
|
(void)use_device_ptr_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> use_device_ptr_varsTypes;
|
|
bool deviceClause = false;
|
|
bool ifClause = false;
|
|
bool map_entriesClause = false;
|
|
bool map_iteratedClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("device"))) {
|
|
|
|
if (deviceClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`device` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
deviceClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
deviceOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
deviceOperands.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();
|
|
deviceTypes.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();
|
|
|
|
{
|
|
if_exprOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
if_exprOperands.push_back(operand);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("map_entries"))) {
|
|
|
|
if (map_entriesClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`map_entries` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
map_entriesClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
map_varsOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(map_varsOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(map_varsTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("map_iterated"))) {
|
|
|
|
if (map_iteratedClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`map_iterated` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
map_iteratedClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
map_iteratedOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(map_iteratedOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(map_iteratedTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
{
|
|
use_device_addr_varsOperandsLoc = parser.getCurrentLocation();
|
|
use_device_ptr_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseUseDeviceAddrUseDevicePtrRegion(parser, *regionRegion, use_device_addr_varsOperands, use_device_addr_varsTypes, use_device_ptr_varsOperands, use_device_ptr_varsTypes);
|
|
if (odsResult) 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));
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(deviceOperands.size()), static_cast<int32_t>(if_exprOperands.size()), static_cast<int32_t>(map_varsOperands.size()), static_cast<int32_t>(map_iteratedOperands.size()), static_cast<int32_t>(use_device_addr_varsOperands.size()), static_cast<int32_t>(use_device_ptr_varsOperands.size())}), result.getOrAddProperties<TargetDataOp::Properties>().operandSegmentSizes.begin());
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1);
|
|
if (!deviceOperands.empty()) {
|
|
if (parser.resolveOperands(deviceOperands, deviceTypes, deviceOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (!if_exprOperands.empty()) {
|
|
if (parser.resolveOperands(if_exprOperands, odsBuildableType0, if_exprOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(map_varsOperands, map_varsTypes, map_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(map_iteratedOperands, map_iteratedTypes, map_iteratedOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(use_device_addr_varsOperands, use_device_addr_varsTypes, use_device_addr_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(use_device_ptr_varsOperands, use_device_ptr_varsTypes, use_device_ptr_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TargetDataOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getDevice()) {
|
|
_odsPrinter << ' ' << "device";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getDevice())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << (getDevice() ? ::llvm::ArrayRef<::mlir::Type>(getDevice().getType()) : ::llvm::ArrayRef<::mlir::Type>());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getIfExpr()) {
|
|
_odsPrinter << ' ' << "if";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getIfExpr())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getMapVars().size()) {
|
|
_odsPrinter << ' ' << "map_entries";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getMapVars();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getMapVars().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getMapIterated().size()) {
|
|
_odsPrinter << ' ' << "map_iterated";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getMapIterated();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getMapIterated().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ';
|
|
printUseDeviceAddrUseDevicePtrRegion(_odsPrinter, *this, getRegion(), getUseDeviceAddrVars(), getUseDeviceAddrVars().getTypes(), getUseDevicePtrVars(), getUseDevicePtrVars().getTypes());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::TargetDataOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::TargetDataOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::TargetEnterDataOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TargetEnterDataOpGenericAdaptorBase::TargetEnterDataOpGenericAdaptorBase(TargetEnterDataOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> TargetEnterDataOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetEnterDataOpGenericAdaptorBase::getDependKinds() {
|
|
auto attr = getDependKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetEnterDataOpGenericAdaptorBase::getDependIteratedKinds() {
|
|
auto attr = getDependIteratedKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr TargetEnterDataOpGenericAdaptorBase::getNowaitAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nowait);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool TargetEnterDataOpGenericAdaptorBase::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
TargetEnterDataOpAdaptor::TargetEnterDataOpAdaptor(TargetEnterDataOp op) : TargetEnterDataOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TargetEnterDataOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_depend_iterated_kinds = getProperties().depend_iterated_kinds; (void)tblgen_depend_iterated_kinds;
|
|
auto tblgen_depend_kinds = getProperties().depend_kinds; (void)tblgen_depend_kinds;
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
|
|
if (tblgen_depend_kinds && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_depend_kinds))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_depend_kinds), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::omp::ClauseTaskDependAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.target_enter_data' op attribute 'depend_kinds' failed to satisfy constraint: depend clause in a target or task construct array");
|
|
|
|
if (tblgen_depend_iterated_kinds && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_depend_iterated_kinds))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_depend_iterated_kinds), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::omp::ClauseTaskDependAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.target_enter_data' op attribute 'depend_iterated_kinds' failed to satisfy constraint: depend clause in a target or task construct array");
|
|
|
|
if (tblgen_nowait && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nowait))))
|
|
return emitError(loc, "'omp.target_enter_data' op attribute 'nowait' failed to satisfy constraint: unit attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> TargetEnterDataOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange TargetEnterDataOp::getDependVarsMutable() {
|
|
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 TargetEnterDataOp::getDependIteratedMutable() {
|
|
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 TargetEnterDataOp::getDeviceMutable() {
|
|
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 TargetEnterDataOp::getIfExprMutable() {
|
|
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 TargetEnterDataOp::getMapVarsMutable() {
|
|
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 TargetEnterDataOp::getMapIteratedMutable() {
|
|
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;
|
|
}
|
|
|
|
::llvm::LogicalResult TargetEnterDataOp::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.depend_iterated_kinds;
|
|
auto attr = dict.get("depend_iterated_kinds");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `depend_iterated_kinds` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.depend_kinds;
|
|
auto attr = dict.get("depend_kinds");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `depend_kinds` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.nowait;
|
|
auto attr = dict.get("nowait");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nowait` 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 TargetEnterDataOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.depend_iterated_kinds;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("depend_iterated_kinds",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.depend_kinds;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("depend_kinds",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.nowait;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nowait",
|
|
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 TargetEnterDataOp::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.depend_iterated_kinds.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.depend_kinds.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.nowait.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TargetEnterDataOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "depend_iterated_kinds")
|
|
return prop.depend_iterated_kinds;
|
|
|
|
if (name == "depend_kinds")
|
|
return prop.depend_kinds;
|
|
|
|
if (name == "nowait")
|
|
return prop.nowait;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TargetEnterDataOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "depend_iterated_kinds") {
|
|
prop.depend_iterated_kinds = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.depend_iterated_kinds)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "depend_kinds") {
|
|
prop.depend_kinds = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.depend_kinds)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "nowait") {
|
|
prop.nowait = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nowait)>>(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 TargetEnterDataOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.depend_iterated_kinds) attrs.append("depend_iterated_kinds", prop.depend_iterated_kinds);
|
|
|
|
if (prop.depend_kinds) attrs.append("depend_kinds", prop.depend_kinds);
|
|
|
|
if (prop.nowait) attrs.append("nowait", prop.nowait);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult TargetEnterDataOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDependIteratedKindsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(attr, "depend_iterated_kinds", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDependKindsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(attr, "depend_kinds", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNowaitAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "nowait", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TargetEnterDataOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.depend_iterated_kinds)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.depend_kinds)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nowait)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(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 TargetEnterDataOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.depend_iterated_kinds);
|
|
|
|
writer.writeOptionalAttribute(prop.depend_kinds);
|
|
|
|
writer.writeOptionalAttribute(prop.nowait);
|
|
|
|
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 > TargetEnterDataOp::getDependKinds() {
|
|
auto attr = getDependKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetEnterDataOp::getDependIteratedKinds() {
|
|
auto attr = getDependIteratedKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool TargetEnterDataOp::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
void TargetEnterDataOp::setNowait(bool attrValue) {
|
|
auto &odsProp = getProperties().nowait;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
TargetEnterDataOp TargetEnterDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const TargetEnterExitUpdateDataOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<TargetEnterDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetEnterDataOp TargetEnterDataOp::create(::mlir::ImplicitLocOpBuilder &builder, const TargetEnterExitUpdateDataOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void TargetEnterDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (device ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
}
|
|
|
|
TargetEnterDataOp TargetEnterDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<TargetEnterDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetEnterDataOp TargetEnterDataOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void TargetEnterDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (device ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetEnterDataOp TargetEnterDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<TargetEnterDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetEnterDataOp TargetEnterDataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void TargetEnterDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (device ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
}
|
|
|
|
TargetEnterDataOp TargetEnterDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<TargetEnterDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetEnterDataOp TargetEnterDataOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void TargetEnterDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (device ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetEnterDataOp TargetEnterDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<TargetEnterDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetEnterDataOp TargetEnterDataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void TargetEnterDataOp::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<TargetEnterDataOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
TargetEnterDataOp TargetEnterDataOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<TargetEnterDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetEnterDataOp TargetEnterDataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void TargetEnterDataOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetEnterDataOp TargetEnterDataOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<TargetEnterDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetEnterDataOp TargetEnterDataOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult TargetEnterDataOp::verifyInvariantsImpl() {
|
|
auto tblgen_depend_iterated_kinds = getProperties().depend_iterated_kinds; (void)tblgen_depend_iterated_kinds;
|
|
auto tblgen_depend_kinds = getProperties().depend_kinds; (void)tblgen_depend_kinds;
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(*this, tblgen_depend_kinds, "depend_kinds")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(*this, tblgen_depend_iterated_kinds, "depend_iterated_kinds")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_nowait, "nowait")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps11(*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_OpenMPOps6(*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_OpenMPOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup4 = getODSOperands(4);
|
|
|
|
for (auto v : valueGroup4) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup5 = getODSOperands(5);
|
|
|
|
for (auto v : valueGroup5) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps11(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TargetEnterDataOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult TargetEnterDataOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> depend_varsOperands;
|
|
::llvm::SMLoc depend_varsOperandsLoc;
|
|
(void)depend_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> depend_varsTypes;
|
|
::mlir::ArrayAttr depend_kindsAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> depend_iteratedOperands;
|
|
::llvm::SMLoc depend_iteratedOperandsLoc;
|
|
(void)depend_iteratedOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> depend_iteratedTypes;
|
|
::mlir::ArrayAttr depend_iterated_kindsAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> deviceOperands;
|
|
::llvm::SMLoc deviceOperandsLoc;
|
|
(void)deviceOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> deviceTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> if_exprOperands;
|
|
::llvm::SMLoc if_exprOperandsLoc;
|
|
(void)if_exprOperandsLoc;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> map_varsOperands;
|
|
::llvm::SMLoc map_varsOperandsLoc;
|
|
(void)map_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> map_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> map_iteratedOperands;
|
|
::llvm::SMLoc map_iteratedOperandsLoc;
|
|
(void)map_iteratedOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> map_iteratedTypes;
|
|
bool dependClause = false;
|
|
bool deviceClause = false;
|
|
bool ifClause = false;
|
|
bool map_entriesClause = false;
|
|
bool map_iteratedClause = false;
|
|
bool nowaitClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("depend"))) {
|
|
|
|
if (dependClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`depend` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
dependClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
depend_varsOperandsLoc = parser.getCurrentLocation();
|
|
depend_iteratedOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseDependVarList(parser, depend_varsOperands, depend_varsTypes, depend_kindsAttr, depend_iteratedOperands, depend_iteratedTypes, depend_iterated_kindsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (depend_kindsAttr)
|
|
result.getOrAddProperties<TargetEnterDataOp::Properties>().depend_kinds = depend_kindsAttr;
|
|
if (depend_iterated_kindsAttr)
|
|
result.getOrAddProperties<TargetEnterDataOp::Properties>().depend_iterated_kinds = depend_iterated_kindsAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("device"))) {
|
|
|
|
if (deviceClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`device` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
deviceClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
deviceOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
deviceOperands.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();
|
|
deviceTypes.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();
|
|
|
|
{
|
|
if_exprOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
if_exprOperands.push_back(operand);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("map_entries"))) {
|
|
|
|
if (map_entriesClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`map_entries` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
map_entriesClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
map_varsOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(map_varsOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(map_varsTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("map_iterated"))) {
|
|
|
|
if (map_iteratedClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`map_iterated` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
map_iteratedClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
map_iteratedOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(map_iteratedOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(map_iteratedTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("nowait"))) {
|
|
|
|
if (nowaitClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`nowait` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
nowaitClause = true;
|
|
result.getOrAddProperties<TargetEnterDataOp::Properties>().nowait = parser.getBuilder().getUnitAttr(); } 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<int32_t>({static_cast<int32_t>(depend_varsOperands.size()), static_cast<int32_t>(depend_iteratedOperands.size()), static_cast<int32_t>(deviceOperands.size()), static_cast<int32_t>(if_exprOperands.size()), static_cast<int32_t>(map_varsOperands.size()), static_cast<int32_t>(map_iteratedOperands.size())}), result.getOrAddProperties<TargetEnterDataOp::Properties>().operandSegmentSizes.begin());
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1);
|
|
if (parser.resolveOperands(depend_varsOperands, depend_varsTypes, depend_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(depend_iteratedOperands, depend_iteratedTypes, depend_iteratedOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!deviceOperands.empty()) {
|
|
if (parser.resolveOperands(deviceOperands, deviceTypes, deviceOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (!if_exprOperands.empty()) {
|
|
if (parser.resolveOperands(if_exprOperands, odsBuildableType0, if_exprOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(map_varsOperands, map_varsTypes, map_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(map_iteratedOperands, map_iteratedTypes, map_iteratedOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TargetEnterDataOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getDependVars().size() || (getDependKindsAttr()) || getDependIterated().size() || (getDependIteratedKindsAttr())) {
|
|
_odsPrinter << ' ' << "depend";
|
|
_odsPrinter << "(";
|
|
printDependVarList(_odsPrinter, *this, getDependVars(), getDependVars().getTypes(), getDependKindsAttr(), getDependIterated(), getDependIterated().getTypes(), getDependIteratedKindsAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getDevice()) {
|
|
_odsPrinter << ' ' << "device";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getDevice())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << (getDevice() ? ::llvm::ArrayRef<::mlir::Type>(getDevice().getType()) : ::llvm::ArrayRef<::mlir::Type>());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getIfExpr()) {
|
|
_odsPrinter << ' ' << "if";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getIfExpr())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getMapVars().size()) {
|
|
_odsPrinter << ' ' << "map_entries";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getMapVars();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getMapVars().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getMapIterated().size()) {
|
|
_odsPrinter << ' ' << "map_iterated";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getMapIterated();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getMapIterated().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getNowaitAttr() && getNowaitAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "nowait";
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("depend_kinds");
|
|
elidedAttrs.push_back("depend_iterated_kinds");
|
|
elidedAttrs.push_back("nowait");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getNowaitAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("nowait");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::TargetEnterDataOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::TargetEnterDataOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::TargetExitDataOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TargetExitDataOpGenericAdaptorBase::TargetExitDataOpGenericAdaptorBase(TargetExitDataOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> TargetExitDataOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetExitDataOpGenericAdaptorBase::getDependKinds() {
|
|
auto attr = getDependKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetExitDataOpGenericAdaptorBase::getDependIteratedKinds() {
|
|
auto attr = getDependIteratedKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr TargetExitDataOpGenericAdaptorBase::getNowaitAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nowait);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool TargetExitDataOpGenericAdaptorBase::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
TargetExitDataOpAdaptor::TargetExitDataOpAdaptor(TargetExitDataOp op) : TargetExitDataOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TargetExitDataOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_depend_iterated_kinds = getProperties().depend_iterated_kinds; (void)tblgen_depend_iterated_kinds;
|
|
auto tblgen_depend_kinds = getProperties().depend_kinds; (void)tblgen_depend_kinds;
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
|
|
if (tblgen_depend_kinds && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_depend_kinds))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_depend_kinds), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::omp::ClauseTaskDependAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.target_exit_data' op attribute 'depend_kinds' failed to satisfy constraint: depend clause in a target or task construct array");
|
|
|
|
if (tblgen_depend_iterated_kinds && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_depend_iterated_kinds))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_depend_iterated_kinds), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::omp::ClauseTaskDependAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.target_exit_data' op attribute 'depend_iterated_kinds' failed to satisfy constraint: depend clause in a target or task construct array");
|
|
|
|
if (tblgen_nowait && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nowait))))
|
|
return emitError(loc, "'omp.target_exit_data' op attribute 'nowait' failed to satisfy constraint: unit attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> TargetExitDataOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange TargetExitDataOp::getDependVarsMutable() {
|
|
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 TargetExitDataOp::getDependIteratedMutable() {
|
|
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 TargetExitDataOp::getDeviceMutable() {
|
|
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 TargetExitDataOp::getIfExprMutable() {
|
|
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 TargetExitDataOp::getMapVarsMutable() {
|
|
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 TargetExitDataOp::getMapIteratedMutable() {
|
|
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;
|
|
}
|
|
|
|
::llvm::LogicalResult TargetExitDataOp::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.depend_iterated_kinds;
|
|
auto attr = dict.get("depend_iterated_kinds");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `depend_iterated_kinds` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.depend_kinds;
|
|
auto attr = dict.get("depend_kinds");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `depend_kinds` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.nowait;
|
|
auto attr = dict.get("nowait");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nowait` 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 TargetExitDataOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.depend_iterated_kinds;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("depend_iterated_kinds",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.depend_kinds;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("depend_kinds",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.nowait;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nowait",
|
|
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 TargetExitDataOp::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.depend_iterated_kinds.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.depend_kinds.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.nowait.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TargetExitDataOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "depend_iterated_kinds")
|
|
return prop.depend_iterated_kinds;
|
|
|
|
if (name == "depend_kinds")
|
|
return prop.depend_kinds;
|
|
|
|
if (name == "nowait")
|
|
return prop.nowait;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TargetExitDataOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "depend_iterated_kinds") {
|
|
prop.depend_iterated_kinds = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.depend_iterated_kinds)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "depend_kinds") {
|
|
prop.depend_kinds = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.depend_kinds)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "nowait") {
|
|
prop.nowait = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nowait)>>(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 TargetExitDataOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.depend_iterated_kinds) attrs.append("depend_iterated_kinds", prop.depend_iterated_kinds);
|
|
|
|
if (prop.depend_kinds) attrs.append("depend_kinds", prop.depend_kinds);
|
|
|
|
if (prop.nowait) attrs.append("nowait", prop.nowait);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult TargetExitDataOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDependIteratedKindsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(attr, "depend_iterated_kinds", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDependKindsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(attr, "depend_kinds", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNowaitAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "nowait", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TargetExitDataOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.depend_iterated_kinds)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.depend_kinds)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nowait)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(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 TargetExitDataOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.depend_iterated_kinds);
|
|
|
|
writer.writeOptionalAttribute(prop.depend_kinds);
|
|
|
|
writer.writeOptionalAttribute(prop.nowait);
|
|
|
|
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 > TargetExitDataOp::getDependKinds() {
|
|
auto attr = getDependKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetExitDataOp::getDependIteratedKinds() {
|
|
auto attr = getDependIteratedKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool TargetExitDataOp::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
void TargetExitDataOp::setNowait(bool attrValue) {
|
|
auto &odsProp = getProperties().nowait;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
TargetExitDataOp TargetExitDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const TargetEnterExitUpdateDataOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<TargetExitDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetExitDataOp TargetExitDataOp::create(::mlir::ImplicitLocOpBuilder &builder, const TargetEnterExitUpdateDataOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void TargetExitDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (device ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
}
|
|
|
|
TargetExitDataOp TargetExitDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<TargetExitDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetExitDataOp TargetExitDataOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void TargetExitDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (device ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetExitDataOp TargetExitDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<TargetExitDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetExitDataOp TargetExitDataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void TargetExitDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (device ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
}
|
|
|
|
TargetExitDataOp TargetExitDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<TargetExitDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetExitDataOp TargetExitDataOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void TargetExitDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (device ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetExitDataOp TargetExitDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<TargetExitDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetExitDataOp TargetExitDataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void TargetExitDataOp::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<TargetExitDataOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
TargetExitDataOp TargetExitDataOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<TargetExitDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetExitDataOp TargetExitDataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void TargetExitDataOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetExitDataOp TargetExitDataOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<TargetExitDataOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetExitDataOp TargetExitDataOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult TargetExitDataOp::verifyInvariantsImpl() {
|
|
auto tblgen_depend_iterated_kinds = getProperties().depend_iterated_kinds; (void)tblgen_depend_iterated_kinds;
|
|
auto tblgen_depend_kinds = getProperties().depend_kinds; (void)tblgen_depend_kinds;
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(*this, tblgen_depend_kinds, "depend_kinds")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(*this, tblgen_depend_iterated_kinds, "depend_iterated_kinds")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_nowait, "nowait")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps11(*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_OpenMPOps6(*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_OpenMPOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup4 = getODSOperands(4);
|
|
|
|
for (auto v : valueGroup4) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup5 = getODSOperands(5);
|
|
|
|
for (auto v : valueGroup5) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps11(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TargetExitDataOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult TargetExitDataOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> depend_varsOperands;
|
|
::llvm::SMLoc depend_varsOperandsLoc;
|
|
(void)depend_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> depend_varsTypes;
|
|
::mlir::ArrayAttr depend_kindsAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> depend_iteratedOperands;
|
|
::llvm::SMLoc depend_iteratedOperandsLoc;
|
|
(void)depend_iteratedOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> depend_iteratedTypes;
|
|
::mlir::ArrayAttr depend_iterated_kindsAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> deviceOperands;
|
|
::llvm::SMLoc deviceOperandsLoc;
|
|
(void)deviceOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> deviceTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> if_exprOperands;
|
|
::llvm::SMLoc if_exprOperandsLoc;
|
|
(void)if_exprOperandsLoc;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> map_varsOperands;
|
|
::llvm::SMLoc map_varsOperandsLoc;
|
|
(void)map_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> map_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> map_iteratedOperands;
|
|
::llvm::SMLoc map_iteratedOperandsLoc;
|
|
(void)map_iteratedOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> map_iteratedTypes;
|
|
bool dependClause = false;
|
|
bool deviceClause = false;
|
|
bool ifClause = false;
|
|
bool map_entriesClause = false;
|
|
bool map_iteratedClause = false;
|
|
bool nowaitClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("depend"))) {
|
|
|
|
if (dependClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`depend` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
dependClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
depend_varsOperandsLoc = parser.getCurrentLocation();
|
|
depend_iteratedOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseDependVarList(parser, depend_varsOperands, depend_varsTypes, depend_kindsAttr, depend_iteratedOperands, depend_iteratedTypes, depend_iterated_kindsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (depend_kindsAttr)
|
|
result.getOrAddProperties<TargetExitDataOp::Properties>().depend_kinds = depend_kindsAttr;
|
|
if (depend_iterated_kindsAttr)
|
|
result.getOrAddProperties<TargetExitDataOp::Properties>().depend_iterated_kinds = depend_iterated_kindsAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("device"))) {
|
|
|
|
if (deviceClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`device` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
deviceClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
deviceOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
deviceOperands.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();
|
|
deviceTypes.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();
|
|
|
|
{
|
|
if_exprOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
if_exprOperands.push_back(operand);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("map_entries"))) {
|
|
|
|
if (map_entriesClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`map_entries` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
map_entriesClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
map_varsOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(map_varsOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(map_varsTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("map_iterated"))) {
|
|
|
|
if (map_iteratedClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`map_iterated` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
map_iteratedClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
map_iteratedOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(map_iteratedOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(map_iteratedTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("nowait"))) {
|
|
|
|
if (nowaitClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`nowait` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
nowaitClause = true;
|
|
result.getOrAddProperties<TargetExitDataOp::Properties>().nowait = parser.getBuilder().getUnitAttr(); } 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<int32_t>({static_cast<int32_t>(depend_varsOperands.size()), static_cast<int32_t>(depend_iteratedOperands.size()), static_cast<int32_t>(deviceOperands.size()), static_cast<int32_t>(if_exprOperands.size()), static_cast<int32_t>(map_varsOperands.size()), static_cast<int32_t>(map_iteratedOperands.size())}), result.getOrAddProperties<TargetExitDataOp::Properties>().operandSegmentSizes.begin());
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1);
|
|
if (parser.resolveOperands(depend_varsOperands, depend_varsTypes, depend_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(depend_iteratedOperands, depend_iteratedTypes, depend_iteratedOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!deviceOperands.empty()) {
|
|
if (parser.resolveOperands(deviceOperands, deviceTypes, deviceOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (!if_exprOperands.empty()) {
|
|
if (parser.resolveOperands(if_exprOperands, odsBuildableType0, if_exprOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(map_varsOperands, map_varsTypes, map_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(map_iteratedOperands, map_iteratedTypes, map_iteratedOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TargetExitDataOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getDependVars().size() || (getDependKindsAttr()) || getDependIterated().size() || (getDependIteratedKindsAttr())) {
|
|
_odsPrinter << ' ' << "depend";
|
|
_odsPrinter << "(";
|
|
printDependVarList(_odsPrinter, *this, getDependVars(), getDependVars().getTypes(), getDependKindsAttr(), getDependIterated(), getDependIterated().getTypes(), getDependIteratedKindsAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getDevice()) {
|
|
_odsPrinter << ' ' << "device";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getDevice())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << (getDevice() ? ::llvm::ArrayRef<::mlir::Type>(getDevice().getType()) : ::llvm::ArrayRef<::mlir::Type>());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getIfExpr()) {
|
|
_odsPrinter << ' ' << "if";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getIfExpr())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getMapVars().size()) {
|
|
_odsPrinter << ' ' << "map_entries";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getMapVars();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getMapVars().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getMapIterated().size()) {
|
|
_odsPrinter << ' ' << "map_iterated";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getMapIterated();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getMapIterated().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getNowaitAttr() && getNowaitAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "nowait";
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("depend_kinds");
|
|
elidedAttrs.push_back("depend_iterated_kinds");
|
|
elidedAttrs.push_back("nowait");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getNowaitAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("nowait");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::TargetExitDataOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::TargetExitDataOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::TargetFreeMemOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TargetFreeMemOpGenericAdaptorBase::TargetFreeMemOpGenericAdaptorBase(TargetFreeMemOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
TargetFreeMemOpAdaptor::TargetFreeMemOpAdaptor(TargetFreeMemOp op) : TargetFreeMemOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TargetFreeMemOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TargetFreeMemOp::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 TargetFreeMemOp::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 TargetFreeMemOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TargetFreeMemOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TargetFreeMemOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void TargetFreeMemOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult TargetFreeMemOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TargetFreeMemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value device, ::mlir::Value heapref) {
|
|
odsState.addOperands(device);
|
|
odsState.addOperands(heapref);
|
|
}
|
|
|
|
TargetFreeMemOp TargetFreeMemOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value device, ::mlir::Value heapref) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(device)>(device), std::forward<decltype(heapref)>(heapref));
|
|
auto __res__ = ::llvm::dyn_cast<TargetFreeMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetFreeMemOp TargetFreeMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value device, ::mlir::Value heapref) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(device)>(device), std::forward<decltype(heapref)>(heapref));
|
|
}
|
|
|
|
void TargetFreeMemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value device, ::mlir::Value heapref) {
|
|
odsState.addOperands(device);
|
|
odsState.addOperands(heapref);
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetFreeMemOp TargetFreeMemOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value device, ::mlir::Value heapref) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(device)>(device), std::forward<decltype(heapref)>(heapref));
|
|
auto __res__ = ::llvm::dyn_cast<TargetFreeMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetFreeMemOp TargetFreeMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value device, ::mlir::Value heapref) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(device)>(device), std::forward<decltype(heapref)>(heapref));
|
|
}
|
|
|
|
void TargetFreeMemOp::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);
|
|
}
|
|
|
|
TargetFreeMemOp TargetFreeMemOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<TargetFreeMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetFreeMemOp TargetFreeMemOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void TargetFreeMemOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetFreeMemOp TargetFreeMemOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<TargetFreeMemOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetFreeMemOp TargetFreeMemOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult TargetFreeMemOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps18(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TargetFreeMemOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult TargetFreeMemOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::OpAsmParser::UnresolvedOperand deviceRawOperand{};
|
|
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> deviceOperands(&deviceRawOperand, 1); ::llvm::SMLoc deviceOperandsLoc;
|
|
(void)deviceOperandsLoc;
|
|
::mlir::OpAsmParser::UnresolvedOperand heaprefRawOperand{};
|
|
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> heaprefOperands(&heaprefRawOperand, 1); ::llvm::SMLoc heaprefOperandsLoc;
|
|
(void)heaprefOperandsLoc;
|
|
::mlir::Type deviceRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> deviceTypes(&deviceRawType, 1);
|
|
::mlir::Type heaprefRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> heaprefTypes(&heaprefRawType, 1);
|
|
|
|
deviceOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperand(deviceRawOperand))
|
|
return ::mlir::failure();
|
|
if (parser.parseComma())
|
|
return ::mlir::failure();
|
|
|
|
heaprefOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperand(heaprefRawOperand))
|
|
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::IntegerType type;
|
|
if (parser.parseCustomTypeWithFallback(type))
|
|
return ::mlir::failure();
|
|
deviceRawType = type;
|
|
}
|
|
if (parser.parseComma())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseType(heaprefRawType))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(deviceOperands, deviceTypes, deviceOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(heaprefOperands, heaprefTypes, heaprefOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TargetFreeMemOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getDevice();
|
|
_odsPrinter << ",";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getHeapref();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
{
|
|
auto type = getDevice().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type))
|
|
_odsPrinter.printStrippedAttrOrType(validType);
|
|
else
|
|
_odsPrinter << type;
|
|
}
|
|
_odsPrinter << ",";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getHeapref().getType();
|
|
}
|
|
|
|
void TargetFreeMemOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
effects.emplace_back(::mlir::MemoryEffects::Free::get(), 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::Free::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::Free::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get());
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::TargetFreeMemOp)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::TargetOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TargetOpGenericAdaptorBase::TargetOpGenericAdaptorBase(TargetOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> TargetOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::UnitAttr TargetOpGenericAdaptorBase::getBareAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().bare);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool TargetOpGenericAdaptorBase::getBare() {
|
|
auto attr = getBareAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetOpGenericAdaptorBase::getDependKinds() {
|
|
auto attr = getDependKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetOpGenericAdaptorBase::getDependIteratedKinds() {
|
|
auto attr = getDependIteratedKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::AccessGroupModifier> TargetOpGenericAdaptorBase::getDynGroupprivateAccessGroup() {
|
|
auto attr = getDynGroupprivateAccessGroupAttr();
|
|
return attr ? ::std::optional<::mlir::omp::AccessGroupModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::FallbackModifier> TargetOpGenericAdaptorBase::getDynGroupprivateFallback() {
|
|
auto attr = getDynGroupprivateFallbackAttr();
|
|
return attr ? ::std::optional<::mlir::omp::FallbackModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> TargetOpGenericAdaptorBase::getInReductionByref() {
|
|
auto attr = getInReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetOpGenericAdaptorBase::getInReductionSyms() {
|
|
auto attr = getInReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr TargetOpGenericAdaptorBase::getNowaitAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nowait);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool TargetOpGenericAdaptorBase::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetOpGenericAdaptorBase::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr TargetOpGenericAdaptorBase::getPrivateNeedsBarrierAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().private_needs_barrier);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool TargetOpGenericAdaptorBase::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<int64_t>> TargetOpGenericAdaptorBase::getPrivateMaps() {
|
|
auto attr = getPrivateMapsAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<int64_t>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
TargetOpAdaptor::TargetOpAdaptor(TargetOp op) : TargetOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TargetOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_bare = getProperties().bare; (void)tblgen_bare;
|
|
auto tblgen_depend_iterated_kinds = getProperties().depend_iterated_kinds; (void)tblgen_depend_iterated_kinds;
|
|
auto tblgen_depend_kinds = getProperties().depend_kinds; (void)tblgen_depend_kinds;
|
|
auto tblgen_dyn_groupprivate_access_group = getProperties().dyn_groupprivate_access_group; (void)tblgen_dyn_groupprivate_access_group;
|
|
auto tblgen_dyn_groupprivate_fallback = getProperties().dyn_groupprivate_fallback; (void)tblgen_dyn_groupprivate_fallback;
|
|
auto tblgen_in_reduction_byref = getProperties().in_reduction_byref; (void)tblgen_in_reduction_byref;
|
|
auto tblgen_in_reduction_syms = getProperties().in_reduction_syms; (void)tblgen_in_reduction_syms;
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
auto tblgen_private_maps = getProperties().private_maps; (void)tblgen_private_maps;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
|
|
if (tblgen_bare && !((::llvm::isa<::mlir::UnitAttr>(tblgen_bare))))
|
|
return emitError(loc, "'omp.target' op attribute 'bare' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_depend_kinds && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_depend_kinds))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_depend_kinds), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::omp::ClauseTaskDependAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.target' op attribute 'depend_kinds' failed to satisfy constraint: depend clause in a target or task construct array");
|
|
|
|
if (tblgen_depend_iterated_kinds && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_depend_iterated_kinds))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_depend_iterated_kinds), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::omp::ClauseTaskDependAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.target' op attribute 'depend_iterated_kinds' failed to satisfy constraint: depend clause in a target or task construct array");
|
|
|
|
if (tblgen_dyn_groupprivate_access_group && !((::llvm::isa<::mlir::omp::AccessGroupModifierAttr>(tblgen_dyn_groupprivate_access_group))))
|
|
return emitError(loc, "'omp.target' op attribute 'dyn_groupprivate_access_group' failed to satisfy constraint: access group modifier");
|
|
|
|
if (tblgen_dyn_groupprivate_fallback && !((::llvm::isa<::mlir::omp::FallbackModifierAttr>(tblgen_dyn_groupprivate_fallback))))
|
|
return emitError(loc, "'omp.target' op attribute 'dyn_groupprivate_fallback' failed to satisfy constraint: fallback modifier");
|
|
|
|
if (tblgen_in_reduction_byref && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(tblgen_in_reduction_byref))))
|
|
return emitError(loc, "'omp.target' op attribute 'in_reduction_byref' failed to satisfy constraint: i1 dense array attribute");
|
|
|
|
if (tblgen_in_reduction_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_in_reduction_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_in_reduction_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.target' op attribute 'in_reduction_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_nowait && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nowait))))
|
|
return emitError(loc, "'omp.target' op attribute 'nowait' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_private_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_private_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_private_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.target' op attribute 'private_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_private_needs_barrier && !((::llvm::isa<::mlir::UnitAttr>(tblgen_private_needs_barrier))))
|
|
return emitError(loc, "'omp.target' op attribute 'private_needs_barrier' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_private_maps && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_private_maps))))
|
|
return emitError(loc, "'omp.target' op attribute 'private_maps' failed to satisfy constraint: i64 dense array attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> TargetOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange TargetOp::getAllocateVarsMutable() {
|
|
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 TargetOp::getAllocatorVarsMutable() {
|
|
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 TargetOp::getDependVarsMutable() {
|
|
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 TargetOp::getDependIteratedMutable() {
|
|
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 TargetOp::getDeviceMutable() {
|
|
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 TargetOp::getDynGroupprivateSizeMutable() {
|
|
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 TargetOp::getHasDeviceAddrVarsMutable() {
|
|
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 TargetOp::getHostEvalVarsMutable() {
|
|
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 TargetOp::getIfExprMutable() {
|
|
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 TargetOp::getInReductionVarsMutable() {
|
|
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 TargetOp::getIsDevicePtrVarsMutable() {
|
|
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;
|
|
}
|
|
|
|
::mlir::MutableOperandRange TargetOp::getMapVarsMutable() {
|
|
auto range = getODSOperandIndexAndLength(11);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(11u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)}));
|
|
return mutableRange;
|
|
}
|
|
|
|
::mlir::MutableOperandRange TargetOp::getMapIteratedMutable() {
|
|
auto range = getODSOperandIndexAndLength(12);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(12u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)}));
|
|
return mutableRange;
|
|
}
|
|
|
|
::mlir::MutableOperandRange TargetOp::getPrivateVarsMutable() {
|
|
auto range = getODSOperandIndexAndLength(13);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(13u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)}));
|
|
return mutableRange;
|
|
}
|
|
|
|
::mlir::MutableOperandRange TargetOp::getThreadLimitVarsMutable() {
|
|
auto range = getODSOperandIndexAndLength(14);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(14u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)}));
|
|
return mutableRange;
|
|
}
|
|
|
|
::llvm::LogicalResult TargetOp::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.bare;
|
|
auto attr = dict.get("bare");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `bare` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.depend_iterated_kinds;
|
|
auto attr = dict.get("depend_iterated_kinds");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `depend_iterated_kinds` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.depend_kinds;
|
|
auto attr = dict.get("depend_kinds");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `depend_kinds` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.dyn_groupprivate_access_group;
|
|
auto attr = dict.get("dyn_groupprivate_access_group");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `dyn_groupprivate_access_group` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.dyn_groupprivate_fallback;
|
|
auto attr = dict.get("dyn_groupprivate_fallback");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `dyn_groupprivate_fallback` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.in_reduction_byref;
|
|
auto attr = dict.get("in_reduction_byref");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `in_reduction_byref` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.in_reduction_syms;
|
|
auto attr = dict.get("in_reduction_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `in_reduction_syms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.nowait;
|
|
auto attr = dict.get("nowait");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nowait` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_maps;
|
|
auto attr = dict.get("private_maps");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_maps` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_needs_barrier;
|
|
auto attr = dict.get("private_needs_barrier");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_needs_barrier` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_syms;
|
|
auto attr = dict.get("private_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_syms` 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 TargetOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.bare;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("bare",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.depend_iterated_kinds;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("depend_iterated_kinds",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.depend_kinds;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("depend_kinds",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.dyn_groupprivate_access_group;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("dyn_groupprivate_access_group",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.dyn_groupprivate_fallback;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("dyn_groupprivate_fallback",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.in_reduction_byref;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("in_reduction_byref",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.in_reduction_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("in_reduction_syms",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.nowait;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nowait",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_maps;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_maps",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_needs_barrier;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_needs_barrier",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_syms",
|
|
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 TargetOp::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.bare.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.depend_iterated_kinds.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.depend_kinds.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.dyn_groupprivate_access_group.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.dyn_groupprivate_fallback.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.in_reduction_byref.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.in_reduction_syms.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.nowait.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_maps.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_needs_barrier.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_syms.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TargetOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "bare")
|
|
return prop.bare;
|
|
|
|
if (name == "depend_iterated_kinds")
|
|
return prop.depend_iterated_kinds;
|
|
|
|
if (name == "depend_kinds")
|
|
return prop.depend_kinds;
|
|
|
|
if (name == "dyn_groupprivate_access_group")
|
|
return prop.dyn_groupprivate_access_group;
|
|
|
|
if (name == "dyn_groupprivate_fallback")
|
|
return prop.dyn_groupprivate_fallback;
|
|
|
|
if (name == "in_reduction_byref")
|
|
return prop.in_reduction_byref;
|
|
|
|
if (name == "in_reduction_syms")
|
|
return prop.in_reduction_syms;
|
|
|
|
if (name == "nowait")
|
|
return prop.nowait;
|
|
|
|
if (name == "private_maps")
|
|
return prop.private_maps;
|
|
|
|
if (name == "private_needs_barrier")
|
|
return prop.private_needs_barrier;
|
|
|
|
if (name == "private_syms")
|
|
return prop.private_syms;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TargetOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "bare") {
|
|
prop.bare = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.bare)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "depend_iterated_kinds") {
|
|
prop.depend_iterated_kinds = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.depend_iterated_kinds)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "depend_kinds") {
|
|
prop.depend_kinds = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.depend_kinds)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "dyn_groupprivate_access_group") {
|
|
prop.dyn_groupprivate_access_group = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.dyn_groupprivate_access_group)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "dyn_groupprivate_fallback") {
|
|
prop.dyn_groupprivate_fallback = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.dyn_groupprivate_fallback)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "in_reduction_byref") {
|
|
prop.in_reduction_byref = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.in_reduction_byref)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "in_reduction_syms") {
|
|
prop.in_reduction_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.in_reduction_syms)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "nowait") {
|
|
prop.nowait = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nowait)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_maps") {
|
|
prop.private_maps = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_maps)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_needs_barrier") {
|
|
prop.private_needs_barrier = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_needs_barrier)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_syms") {
|
|
prop.private_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_syms)>>(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 TargetOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.bare) attrs.append("bare", prop.bare);
|
|
|
|
if (prop.depend_iterated_kinds) attrs.append("depend_iterated_kinds", prop.depend_iterated_kinds);
|
|
|
|
if (prop.depend_kinds) attrs.append("depend_kinds", prop.depend_kinds);
|
|
|
|
if (prop.dyn_groupprivate_access_group) attrs.append("dyn_groupprivate_access_group", prop.dyn_groupprivate_access_group);
|
|
|
|
if (prop.dyn_groupprivate_fallback) attrs.append("dyn_groupprivate_fallback", prop.dyn_groupprivate_fallback);
|
|
|
|
if (prop.in_reduction_byref) attrs.append("in_reduction_byref", prop.in_reduction_byref);
|
|
|
|
if (prop.in_reduction_syms) attrs.append("in_reduction_syms", prop.in_reduction_syms);
|
|
|
|
if (prop.nowait) attrs.append("nowait", prop.nowait);
|
|
|
|
if (prop.private_maps) attrs.append("private_maps", prop.private_maps);
|
|
|
|
if (prop.private_needs_barrier) attrs.append("private_needs_barrier", prop.private_needs_barrier);
|
|
|
|
if (prop.private_syms) attrs.append("private_syms", prop.private_syms);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult TargetOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getBareAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "bare", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDependIteratedKindsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(attr, "depend_iterated_kinds", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDependKindsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(attr, "depend_kinds", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDynGroupprivateAccessGroupAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps31(attr, "dyn_groupprivate_access_group", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDynGroupprivateFallbackAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps32(attr, "dyn_groupprivate_fallback", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getInReductionByrefAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(attr, "in_reduction_byref", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getInReductionSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "in_reduction_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNowaitAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "nowait", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateMapsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps17(attr, "private_maps", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateNeedsBarrierAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "private_needs_barrier", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "private_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TargetOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.bare)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.depend_iterated_kinds)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.depend_kinds)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.dyn_groupprivate_access_group)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.dyn_groupprivate_fallback)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.in_reduction_byref)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.in_reduction_syms)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nowait)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_maps)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_needs_barrier)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_syms)))
|
|
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 TargetOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.bare);
|
|
|
|
writer.writeOptionalAttribute(prop.depend_iterated_kinds);
|
|
|
|
writer.writeOptionalAttribute(prop.depend_kinds);
|
|
|
|
writer.writeOptionalAttribute(prop.dyn_groupprivate_access_group);
|
|
|
|
writer.writeOptionalAttribute(prop.dyn_groupprivate_fallback);
|
|
|
|
writer.writeOptionalAttribute(prop.in_reduction_byref);
|
|
|
|
writer.writeOptionalAttribute(prop.in_reduction_syms);
|
|
|
|
writer.writeOptionalAttribute(prop.nowait);
|
|
|
|
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
|
|
}
|
|
|
|
writer.writeOptionalAttribute(prop.private_maps);
|
|
|
|
writer.writeOptionalAttribute(prop.private_needs_barrier);
|
|
|
|
writer.writeOptionalAttribute(prop.private_syms);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
bool TargetOp::getBare() {
|
|
auto attr = getBareAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetOp::getDependKinds() {
|
|
auto attr = getDependKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetOp::getDependIteratedKinds() {
|
|
auto attr = getDependIteratedKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::AccessGroupModifier> TargetOp::getDynGroupprivateAccessGroup() {
|
|
auto attr = getDynGroupprivateAccessGroupAttr();
|
|
return attr ? ::std::optional<::mlir::omp::AccessGroupModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::FallbackModifier> TargetOp::getDynGroupprivateFallback() {
|
|
auto attr = getDynGroupprivateFallbackAttr();
|
|
return attr ? ::std::optional<::mlir::omp::FallbackModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> TargetOp::getInReductionByref() {
|
|
auto attr = getInReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetOp::getInReductionSyms() {
|
|
auto attr = getInReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool TargetOp::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetOp::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool TargetOp::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<int64_t>> TargetOp::getPrivateMaps() {
|
|
auto attr = getPrivateMapsAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<int64_t>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
void TargetOp::setBare(bool attrValue) {
|
|
auto &odsProp = getProperties().bare;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TargetOp::setDynGroupprivateAccessGroup(::std::optional<::mlir::omp::AccessGroupModifier> attrValue) {
|
|
auto &odsProp = getProperties().dyn_groupprivate_access_group;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::AccessGroupModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TargetOp::setDynGroupprivateFallback(::std::optional<::mlir::omp::FallbackModifier> attrValue) {
|
|
auto &odsProp = getProperties().dyn_groupprivate_fallback;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::FallbackModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TargetOp::setInReductionByref(::std::optional<::llvm::ArrayRef<bool>> attrValue) {
|
|
auto &odsProp = getProperties().in_reduction_byref;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getDenseBoolArrayAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TargetOp::setNowait(bool attrValue) {
|
|
auto &odsProp = getProperties().nowait;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TargetOp::setPrivateNeedsBarrier(bool attrValue) {
|
|
auto &odsProp = getProperties().private_needs_barrier;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TargetOp::setPrivateMaps(::std::optional<::llvm::ArrayRef<int64_t>> attrValue) {
|
|
auto &odsProp = getProperties().private_maps;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
TargetOp TargetOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const TargetOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<TargetOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetOp TargetOp::create(::mlir::ImplicitLocOpBuilder &builder, const TargetOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void TargetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr bare, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, ::mlir::ValueRange has_device_addr_vars, ::mlir::ValueRange host_eval_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, ::mlir::ValueRange is_device_ptr_vars, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, ::mlir::ValueRange thread_limit_vars, /*optional*/::mlir::DenseI64ArrayAttr private_maps) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (dyn_groupprivate_size)
|
|
odsState.addOperands(dyn_groupprivate_size);
|
|
odsState.addOperands(has_device_addr_vars);
|
|
odsState.addOperands(host_eval_vars);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(in_reduction_vars);
|
|
odsState.addOperands(is_device_ptr_vars);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(thread_limit_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (device ? 1 : 0), (dyn_groupprivate_size ? 1 : 0), static_cast<int32_t>(has_device_addr_vars.size()), static_cast<int32_t>(host_eval_vars.size()), (if_expr ? 1 : 0), static_cast<int32_t>(in_reduction_vars.size()), static_cast<int32_t>(is_device_ptr_vars.size()), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(thread_limit_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (bare) {
|
|
odsState.getOrAddProperties<Properties>().bare = bare;
|
|
}
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (dyn_groupprivate_access_group) {
|
|
odsState.getOrAddProperties<Properties>().dyn_groupprivate_access_group = dyn_groupprivate_access_group;
|
|
}
|
|
if (dyn_groupprivate_fallback) {
|
|
odsState.getOrAddProperties<Properties>().dyn_groupprivate_fallback = dyn_groupprivate_fallback;
|
|
}
|
|
if (in_reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_byref = in_reduction_byref;
|
|
}
|
|
if (in_reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_syms = in_reduction_syms;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (private_maps) {
|
|
odsState.getOrAddProperties<Properties>().private_maps = private_maps;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
TargetOp TargetOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr bare, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, ::mlir::ValueRange has_device_addr_vars, ::mlir::ValueRange host_eval_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, ::mlir::ValueRange is_device_ptr_vars, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, ::mlir::ValueRange thread_limit_vars, /*optional*/::mlir::DenseI64ArrayAttr private_maps) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(bare)>(bare), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(dyn_groupprivate_access_group)>(dyn_groupprivate_access_group), std::forward<decltype(dyn_groupprivate_fallback)>(dyn_groupprivate_fallback), std::forward<decltype(dyn_groupprivate_size)>(dyn_groupprivate_size), std::forward<decltype(has_device_addr_vars)>(has_device_addr_vars), std::forward<decltype(host_eval_vars)>(host_eval_vars), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(is_device_ptr_vars)>(is_device_ptr_vars), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(thread_limit_vars)>(thread_limit_vars), std::forward<decltype(private_maps)>(private_maps));
|
|
auto __res__ = ::llvm::dyn_cast<TargetOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetOp TargetOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr bare, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, ::mlir::ValueRange has_device_addr_vars, ::mlir::ValueRange host_eval_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, ::mlir::ValueRange is_device_ptr_vars, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, ::mlir::ValueRange thread_limit_vars, /*optional*/::mlir::DenseI64ArrayAttr private_maps) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(bare)>(bare), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(dyn_groupprivate_access_group)>(dyn_groupprivate_access_group), std::forward<decltype(dyn_groupprivate_fallback)>(dyn_groupprivate_fallback), std::forward<decltype(dyn_groupprivate_size)>(dyn_groupprivate_size), std::forward<decltype(has_device_addr_vars)>(has_device_addr_vars), std::forward<decltype(host_eval_vars)>(host_eval_vars), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(is_device_ptr_vars)>(is_device_ptr_vars), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(thread_limit_vars)>(thread_limit_vars), std::forward<decltype(private_maps)>(private_maps));
|
|
}
|
|
|
|
void TargetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr bare, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, ::mlir::ValueRange has_device_addr_vars, ::mlir::ValueRange host_eval_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, ::mlir::ValueRange is_device_ptr_vars, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, ::mlir::ValueRange thread_limit_vars, /*optional*/::mlir::DenseI64ArrayAttr private_maps) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (dyn_groupprivate_size)
|
|
odsState.addOperands(dyn_groupprivate_size);
|
|
odsState.addOperands(has_device_addr_vars);
|
|
odsState.addOperands(host_eval_vars);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(in_reduction_vars);
|
|
odsState.addOperands(is_device_ptr_vars);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(thread_limit_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (device ? 1 : 0), (dyn_groupprivate_size ? 1 : 0), static_cast<int32_t>(has_device_addr_vars.size()), static_cast<int32_t>(host_eval_vars.size()), (if_expr ? 1 : 0), static_cast<int32_t>(in_reduction_vars.size()), static_cast<int32_t>(is_device_ptr_vars.size()), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(thread_limit_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (bare) {
|
|
odsState.getOrAddProperties<Properties>().bare = bare;
|
|
}
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (dyn_groupprivate_access_group) {
|
|
odsState.getOrAddProperties<Properties>().dyn_groupprivate_access_group = dyn_groupprivate_access_group;
|
|
}
|
|
if (dyn_groupprivate_fallback) {
|
|
odsState.getOrAddProperties<Properties>().dyn_groupprivate_fallback = dyn_groupprivate_fallback;
|
|
}
|
|
if (in_reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_byref = in_reduction_byref;
|
|
}
|
|
if (in_reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_syms = in_reduction_syms;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (private_maps) {
|
|
odsState.getOrAddProperties<Properties>().private_maps = private_maps;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetOp TargetOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr bare, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, ::mlir::ValueRange has_device_addr_vars, ::mlir::ValueRange host_eval_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, ::mlir::ValueRange is_device_ptr_vars, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, ::mlir::ValueRange thread_limit_vars, /*optional*/::mlir::DenseI64ArrayAttr private_maps) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(bare)>(bare), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(dyn_groupprivate_access_group)>(dyn_groupprivate_access_group), std::forward<decltype(dyn_groupprivate_fallback)>(dyn_groupprivate_fallback), std::forward<decltype(dyn_groupprivate_size)>(dyn_groupprivate_size), std::forward<decltype(has_device_addr_vars)>(has_device_addr_vars), std::forward<decltype(host_eval_vars)>(host_eval_vars), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(is_device_ptr_vars)>(is_device_ptr_vars), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(thread_limit_vars)>(thread_limit_vars), std::forward<decltype(private_maps)>(private_maps));
|
|
auto __res__ = ::llvm::dyn_cast<TargetOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetOp TargetOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::UnitAttr bare, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, ::mlir::ValueRange has_device_addr_vars, ::mlir::ValueRange host_eval_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, ::mlir::ValueRange is_device_ptr_vars, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, ::mlir::ValueRange thread_limit_vars, /*optional*/::mlir::DenseI64ArrayAttr private_maps) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(bare)>(bare), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(dyn_groupprivate_access_group)>(dyn_groupprivate_access_group), std::forward<decltype(dyn_groupprivate_fallback)>(dyn_groupprivate_fallback), std::forward<decltype(dyn_groupprivate_size)>(dyn_groupprivate_size), std::forward<decltype(has_device_addr_vars)>(has_device_addr_vars), std::forward<decltype(host_eval_vars)>(host_eval_vars), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(is_device_ptr_vars)>(is_device_ptr_vars), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(thread_limit_vars)>(thread_limit_vars), std::forward<decltype(private_maps)>(private_maps));
|
|
}
|
|
|
|
void TargetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool bare, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, ::mlir::ValueRange has_device_addr_vars, ::mlir::ValueRange host_eval_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, ::mlir::ValueRange is_device_ptr_vars, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, ::mlir::ValueRange thread_limit_vars, /*optional*/::mlir::DenseI64ArrayAttr private_maps) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (dyn_groupprivate_size)
|
|
odsState.addOperands(dyn_groupprivate_size);
|
|
odsState.addOperands(has_device_addr_vars);
|
|
odsState.addOperands(host_eval_vars);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(in_reduction_vars);
|
|
odsState.addOperands(is_device_ptr_vars);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(thread_limit_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (device ? 1 : 0), (dyn_groupprivate_size ? 1 : 0), static_cast<int32_t>(has_device_addr_vars.size()), static_cast<int32_t>(host_eval_vars.size()), (if_expr ? 1 : 0), static_cast<int32_t>(in_reduction_vars.size()), static_cast<int32_t>(is_device_ptr_vars.size()), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(thread_limit_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (bare) {
|
|
odsState.getOrAddProperties<Properties>().bare = ((bare) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (dyn_groupprivate_access_group) {
|
|
odsState.getOrAddProperties<Properties>().dyn_groupprivate_access_group = dyn_groupprivate_access_group;
|
|
}
|
|
if (dyn_groupprivate_fallback) {
|
|
odsState.getOrAddProperties<Properties>().dyn_groupprivate_fallback = dyn_groupprivate_fallback;
|
|
}
|
|
if (in_reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_byref = in_reduction_byref;
|
|
}
|
|
if (in_reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_syms = in_reduction_syms;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (private_maps) {
|
|
odsState.getOrAddProperties<Properties>().private_maps = private_maps;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
TargetOp TargetOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool bare, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, ::mlir::ValueRange has_device_addr_vars, ::mlir::ValueRange host_eval_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, ::mlir::ValueRange is_device_ptr_vars, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, ::mlir::ValueRange thread_limit_vars, /*optional*/::mlir::DenseI64ArrayAttr private_maps) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(bare)>(bare), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(dyn_groupprivate_access_group)>(dyn_groupprivate_access_group), std::forward<decltype(dyn_groupprivate_fallback)>(dyn_groupprivate_fallback), std::forward<decltype(dyn_groupprivate_size)>(dyn_groupprivate_size), std::forward<decltype(has_device_addr_vars)>(has_device_addr_vars), std::forward<decltype(host_eval_vars)>(host_eval_vars), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(is_device_ptr_vars)>(is_device_ptr_vars), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(thread_limit_vars)>(thread_limit_vars), std::forward<decltype(private_maps)>(private_maps));
|
|
auto __res__ = ::llvm::dyn_cast<TargetOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetOp TargetOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool bare, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, ::mlir::ValueRange has_device_addr_vars, ::mlir::ValueRange host_eval_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, ::mlir::ValueRange is_device_ptr_vars, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, ::mlir::ValueRange thread_limit_vars, /*optional*/::mlir::DenseI64ArrayAttr private_maps) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(bare)>(bare), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(dyn_groupprivate_access_group)>(dyn_groupprivate_access_group), std::forward<decltype(dyn_groupprivate_fallback)>(dyn_groupprivate_fallback), std::forward<decltype(dyn_groupprivate_size)>(dyn_groupprivate_size), std::forward<decltype(has_device_addr_vars)>(has_device_addr_vars), std::forward<decltype(host_eval_vars)>(host_eval_vars), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(is_device_ptr_vars)>(is_device_ptr_vars), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(thread_limit_vars)>(thread_limit_vars), std::forward<decltype(private_maps)>(private_maps));
|
|
}
|
|
|
|
void TargetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool bare, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, ::mlir::ValueRange has_device_addr_vars, ::mlir::ValueRange host_eval_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, ::mlir::ValueRange is_device_ptr_vars, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, ::mlir::ValueRange thread_limit_vars, /*optional*/::mlir::DenseI64ArrayAttr private_maps) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (dyn_groupprivate_size)
|
|
odsState.addOperands(dyn_groupprivate_size);
|
|
odsState.addOperands(has_device_addr_vars);
|
|
odsState.addOperands(host_eval_vars);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(in_reduction_vars);
|
|
odsState.addOperands(is_device_ptr_vars);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(thread_limit_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (device ? 1 : 0), (dyn_groupprivate_size ? 1 : 0), static_cast<int32_t>(has_device_addr_vars.size()), static_cast<int32_t>(host_eval_vars.size()), (if_expr ? 1 : 0), static_cast<int32_t>(in_reduction_vars.size()), static_cast<int32_t>(is_device_ptr_vars.size()), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(thread_limit_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (bare) {
|
|
odsState.getOrAddProperties<Properties>().bare = ((bare) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (dyn_groupprivate_access_group) {
|
|
odsState.getOrAddProperties<Properties>().dyn_groupprivate_access_group = dyn_groupprivate_access_group;
|
|
}
|
|
if (dyn_groupprivate_fallback) {
|
|
odsState.getOrAddProperties<Properties>().dyn_groupprivate_fallback = dyn_groupprivate_fallback;
|
|
}
|
|
if (in_reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_byref = in_reduction_byref;
|
|
}
|
|
if (in_reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_syms = in_reduction_syms;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (private_maps) {
|
|
odsState.getOrAddProperties<Properties>().private_maps = private_maps;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetOp TargetOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool bare, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, ::mlir::ValueRange has_device_addr_vars, ::mlir::ValueRange host_eval_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, ::mlir::ValueRange is_device_ptr_vars, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, ::mlir::ValueRange thread_limit_vars, /*optional*/::mlir::DenseI64ArrayAttr private_maps) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(bare)>(bare), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(dyn_groupprivate_access_group)>(dyn_groupprivate_access_group), std::forward<decltype(dyn_groupprivate_fallback)>(dyn_groupprivate_fallback), std::forward<decltype(dyn_groupprivate_size)>(dyn_groupprivate_size), std::forward<decltype(has_device_addr_vars)>(has_device_addr_vars), std::forward<decltype(host_eval_vars)>(host_eval_vars), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(is_device_ptr_vars)>(is_device_ptr_vars), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(thread_limit_vars)>(thread_limit_vars), std::forward<decltype(private_maps)>(private_maps));
|
|
auto __res__ = ::llvm::dyn_cast<TargetOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetOp TargetOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/bool bare, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, ::mlir::ValueRange has_device_addr_vars, ::mlir::ValueRange host_eval_vars, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, ::mlir::ValueRange is_device_ptr_vars, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, ::mlir::ValueRange thread_limit_vars, /*optional*/::mlir::DenseI64ArrayAttr private_maps) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(bare)>(bare), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(dyn_groupprivate_access_group)>(dyn_groupprivate_access_group), std::forward<decltype(dyn_groupprivate_fallback)>(dyn_groupprivate_fallback), std::forward<decltype(dyn_groupprivate_size)>(dyn_groupprivate_size), std::forward<decltype(has_device_addr_vars)>(has_device_addr_vars), std::forward<decltype(host_eval_vars)>(host_eval_vars), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(is_device_ptr_vars)>(is_device_ptr_vars), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(thread_limit_vars)>(thread_limit_vars), std::forward<decltype(private_maps)>(private_maps));
|
|
}
|
|
|
|
void TargetOp::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<TargetOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
TargetOp TargetOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<TargetOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetOp TargetOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void TargetOp::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&>(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);
|
|
}
|
|
|
|
TargetOp TargetOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<TargetOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetOp TargetOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult TargetOp::verifyInvariantsImpl() {
|
|
auto tblgen_bare = getProperties().bare; (void)tblgen_bare;
|
|
auto tblgen_depend_iterated_kinds = getProperties().depend_iterated_kinds; (void)tblgen_depend_iterated_kinds;
|
|
auto tblgen_depend_kinds = getProperties().depend_kinds; (void)tblgen_depend_kinds;
|
|
auto tblgen_dyn_groupprivate_access_group = getProperties().dyn_groupprivate_access_group; (void)tblgen_dyn_groupprivate_access_group;
|
|
auto tblgen_dyn_groupprivate_fallback = getProperties().dyn_groupprivate_fallback; (void)tblgen_dyn_groupprivate_fallback;
|
|
auto tblgen_in_reduction_byref = getProperties().in_reduction_byref; (void)tblgen_in_reduction_byref;
|
|
auto tblgen_in_reduction_syms = getProperties().in_reduction_syms; (void)tblgen_in_reduction_syms;
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
auto tblgen_private_maps = getProperties().private_maps; (void)tblgen_private_maps;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_bare, "bare")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(*this, tblgen_depend_kinds, "depend_kinds")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(*this, tblgen_depend_iterated_kinds, "depend_iterated_kinds")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps31(*this, tblgen_dyn_groupprivate_access_group, "dyn_groupprivate_access_group")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps32(*this, tblgen_dyn_groupprivate_fallback, "dyn_groupprivate_fallback")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(*this, tblgen_in_reduction_byref, "in_reduction_byref")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_in_reduction_syms, "in_reduction_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_nowait, "nowait")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_private_syms, "private_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_private_needs_barrier, "private_needs_barrier")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps17(*this, tblgen_private_maps, "private_maps")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps11(*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_OpenMPOps6(*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_OpenMPOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup6 = getODSOperands(6);
|
|
|
|
for (auto v : valueGroup6) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup7 = getODSOperands(7);
|
|
|
|
for (auto v : valueGroup7) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup8 = getODSOperands(8);
|
|
|
|
if (valueGroup8.size() > 1) {
|
|
return emitOpError("operand group starting at #") << index
|
|
<< " requires 0 or 1 element, but found " << valueGroup8.size();
|
|
}
|
|
|
|
for (auto v : valueGroup8) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup9 = getODSOperands(9);
|
|
|
|
for (auto v : valueGroup9) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup10 = getODSOperands(10);
|
|
|
|
for (auto v : valueGroup10) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup11 = getODSOperands(11);
|
|
|
|
for (auto v : valueGroup11) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup12 = getODSOperands(12);
|
|
|
|
for (auto v : valueGroup12) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps11(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup13 = getODSOperands(13);
|
|
|
|
for (auto v : valueGroup13) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup14 = getODSOperands(14);
|
|
|
|
for (auto v : valueGroup14) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps14(*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_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TargetOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult TargetOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocate_varsOperands;
|
|
::llvm::SMLoc allocate_varsOperandsLoc;
|
|
(void)allocate_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocate_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocator_varsOperands;
|
|
::llvm::SMLoc allocator_varsOperandsLoc;
|
|
(void)allocator_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocator_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> depend_varsOperands;
|
|
::llvm::SMLoc depend_varsOperandsLoc;
|
|
(void)depend_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> depend_varsTypes;
|
|
::mlir::ArrayAttr depend_kindsAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> depend_iteratedOperands;
|
|
::llvm::SMLoc depend_iteratedOperandsLoc;
|
|
(void)depend_iteratedOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> depend_iteratedTypes;
|
|
::mlir::ArrayAttr depend_iterated_kindsAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> deviceOperands;
|
|
::llvm::SMLoc deviceOperandsLoc;
|
|
(void)deviceOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> deviceTypes;
|
|
::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_groupAttr;
|
|
::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallbackAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dyn_groupprivate_sizeOperands;
|
|
::llvm::SMLoc dyn_groupprivate_sizeOperandsLoc;
|
|
(void)dyn_groupprivate_sizeOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> dyn_groupprivate_sizeTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> if_exprOperands;
|
|
::llvm::SMLoc if_exprOperandsLoc;
|
|
(void)if_exprOperandsLoc;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> is_device_ptr_varsOperands;
|
|
::llvm::SMLoc is_device_ptr_varsOperandsLoc;
|
|
(void)is_device_ptr_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> is_device_ptr_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> thread_limit_varsOperands;
|
|
::llvm::SMLoc thread_limit_varsOperandsLoc;
|
|
(void)thread_limit_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> thread_limit_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> map_iteratedOperands;
|
|
::llvm::SMLoc map_iteratedOperandsLoc;
|
|
(void)map_iteratedOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> map_iteratedTypes;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> has_device_addr_varsOperands;
|
|
::llvm::SMLoc has_device_addr_varsOperandsLoc;
|
|
(void)has_device_addr_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> has_device_addr_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> host_eval_varsOperands;
|
|
::llvm::SMLoc host_eval_varsOperandsLoc;
|
|
(void)host_eval_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> host_eval_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> in_reduction_varsOperands;
|
|
::llvm::SMLoc in_reduction_varsOperandsLoc;
|
|
(void)in_reduction_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> in_reduction_varsTypes;
|
|
::mlir::DenseBoolArrayAttr in_reduction_byrefAttr;
|
|
::mlir::ArrayAttr in_reduction_symsAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> map_varsOperands;
|
|
::llvm::SMLoc map_varsOperandsLoc;
|
|
(void)map_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> map_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> private_varsOperands;
|
|
::llvm::SMLoc private_varsOperandsLoc;
|
|
(void)private_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> private_varsTypes;
|
|
::mlir::ArrayAttr private_symsAttr;
|
|
::mlir::UnitAttr private_needs_barrierAttr;
|
|
::mlir::DenseI64ArrayAttr private_mapsAttr;
|
|
bool allocateClause = false;
|
|
bool ompx_bareClause = false;
|
|
bool dependClause = false;
|
|
bool deviceClause = false;
|
|
bool dyn_groupprivateClause = false;
|
|
bool ifClause = false;
|
|
bool is_device_ptrClause = false;
|
|
bool nowaitClause = false;
|
|
bool thread_limitClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("allocate"))) {
|
|
|
|
if (allocateClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`allocate` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
allocateClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
allocate_varsOperandsLoc = parser.getCurrentLocation();
|
|
allocator_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseAllocateAndAllocator(parser, allocate_varsOperands, allocate_varsTypes, allocator_varsOperands, allocator_varsTypes);
|
|
if (odsResult) return ::mlir::failure();
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("ompx_bare"))) {
|
|
|
|
if (ompx_bareClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`ompx_bare` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
ompx_bareClause = true;
|
|
result.getOrAddProperties<TargetOp::Properties>().bare = parser.getBuilder().getUnitAttr(); } else if (succeeded(parser.parseOptionalKeyword("depend"))) {
|
|
|
|
if (dependClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`depend` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
dependClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
depend_varsOperandsLoc = parser.getCurrentLocation();
|
|
depend_iteratedOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseDependVarList(parser, depend_varsOperands, depend_varsTypes, depend_kindsAttr, depend_iteratedOperands, depend_iteratedTypes, depend_iterated_kindsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (depend_kindsAttr)
|
|
result.getOrAddProperties<TargetOp::Properties>().depend_kinds = depend_kindsAttr;
|
|
if (depend_iterated_kindsAttr)
|
|
result.getOrAddProperties<TargetOp::Properties>().depend_iterated_kinds = depend_iterated_kindsAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("device"))) {
|
|
|
|
if (deviceClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`device` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
deviceClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
deviceOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
deviceOperands.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();
|
|
deviceTypes.push_back(optionalType);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("dyn_groupprivate"))) {
|
|
|
|
if (dyn_groupprivateClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`dyn_groupprivate` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
dyn_groupprivateClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
dyn_groupprivate_sizeOperandsLoc = parser.getCurrentLocation();
|
|
::std::optional<::mlir::OpAsmParser::UnresolvedOperand> dyn_groupprivate_sizeOperand;
|
|
::mlir::Type dyn_groupprivate_sizeType;
|
|
auto odsResult = parseDynGroupprivateClause(parser, dyn_groupprivate_access_groupAttr, dyn_groupprivate_fallbackAttr, dyn_groupprivate_sizeOperand, dyn_groupprivate_sizeType);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (dyn_groupprivate_access_groupAttr)
|
|
result.getOrAddProperties<TargetOp::Properties>().dyn_groupprivate_access_group = dyn_groupprivate_access_groupAttr;
|
|
if (dyn_groupprivate_fallbackAttr)
|
|
result.getOrAddProperties<TargetOp::Properties>().dyn_groupprivate_fallback = dyn_groupprivate_fallbackAttr;
|
|
if (dyn_groupprivate_sizeOperand.has_value())
|
|
dyn_groupprivate_sizeOperands.push_back(*dyn_groupprivate_sizeOperand);
|
|
if (dyn_groupprivate_sizeType)
|
|
dyn_groupprivate_sizeTypes.push_back(dyn_groupprivate_sizeType);
|
|
}
|
|
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();
|
|
|
|
{
|
|
if_exprOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
if_exprOperands.push_back(operand);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("is_device_ptr"))) {
|
|
|
|
if (is_device_ptrClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`is_device_ptr` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
is_device_ptrClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
is_device_ptr_varsOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(is_device_ptr_varsOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(is_device_ptr_varsTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("nowait"))) {
|
|
|
|
if (nowaitClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`nowait` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
nowaitClause = true;
|
|
result.getOrAddProperties<TargetOp::Properties>().nowait = parser.getBuilder().getUnitAttr(); } else if (succeeded(parser.parseOptionalKeyword("thread_limit"))) {
|
|
|
|
if (thread_limitClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`thread_limit` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
thread_limitClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
thread_limit_varsOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(thread_limit_varsOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(thread_limit_varsTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
if (::mlir::succeeded(parser.parseOptionalKeyword("map_iterated"))) {
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
map_iteratedOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(map_iteratedOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(map_iteratedTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
}
|
|
{
|
|
has_device_addr_varsOperandsLoc = parser.getCurrentLocation();
|
|
host_eval_varsOperandsLoc = parser.getCurrentLocation();
|
|
in_reduction_varsOperandsLoc = parser.getCurrentLocation();
|
|
map_varsOperandsLoc = parser.getCurrentLocation();
|
|
private_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseTargetOpRegion(parser, *regionRegion, has_device_addr_varsOperands, has_device_addr_varsTypes, host_eval_varsOperands, host_eval_varsTypes, in_reduction_varsOperands, in_reduction_varsTypes, in_reduction_byrefAttr, in_reduction_symsAttr, map_varsOperands, map_varsTypes, private_varsOperands, private_varsTypes, private_symsAttr, private_needs_barrierAttr, private_mapsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (in_reduction_byrefAttr)
|
|
result.getOrAddProperties<TargetOp::Properties>().in_reduction_byref = in_reduction_byrefAttr;
|
|
if (in_reduction_symsAttr)
|
|
result.getOrAddProperties<TargetOp::Properties>().in_reduction_syms = in_reduction_symsAttr;
|
|
if (private_symsAttr)
|
|
result.getOrAddProperties<TargetOp::Properties>().private_syms = private_symsAttr;
|
|
if (private_needs_barrierAttr)
|
|
result.getOrAddProperties<TargetOp::Properties>().private_needs_barrier = private_needs_barrierAttr;
|
|
if (private_mapsAttr)
|
|
result.getOrAddProperties<TargetOp::Properties>().private_maps = private_mapsAttr;
|
|
}
|
|
{
|
|
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<int32_t>({static_cast<int32_t>(allocate_varsOperands.size()), static_cast<int32_t>(allocator_varsOperands.size()), static_cast<int32_t>(depend_varsOperands.size()), static_cast<int32_t>(depend_iteratedOperands.size()), static_cast<int32_t>(deviceOperands.size()), static_cast<int32_t>(dyn_groupprivate_sizeOperands.size()), static_cast<int32_t>(has_device_addr_varsOperands.size()), static_cast<int32_t>(host_eval_varsOperands.size()), static_cast<int32_t>(if_exprOperands.size()), static_cast<int32_t>(in_reduction_varsOperands.size()), static_cast<int32_t>(is_device_ptr_varsOperands.size()), static_cast<int32_t>(map_varsOperands.size()), static_cast<int32_t>(map_iteratedOperands.size()), static_cast<int32_t>(private_varsOperands.size()), static_cast<int32_t>(thread_limit_varsOperands.size())}), result.getOrAddProperties<TargetOp::Properties>().operandSegmentSizes.begin());
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1);
|
|
if (parser.resolveOperands(allocate_varsOperands, allocate_varsTypes, allocate_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(allocator_varsOperands, allocator_varsTypes, allocator_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(depend_varsOperands, depend_varsTypes, depend_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(depend_iteratedOperands, depend_iteratedTypes, depend_iteratedOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!deviceOperands.empty()) {
|
|
if (parser.resolveOperands(deviceOperands, deviceTypes, deviceOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (!dyn_groupprivate_sizeOperands.empty()) {
|
|
if (parser.resolveOperands(dyn_groupprivate_sizeOperands, dyn_groupprivate_sizeTypes, dyn_groupprivate_sizeOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(has_device_addr_varsOperands, has_device_addr_varsTypes, has_device_addr_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(host_eval_varsOperands, host_eval_varsTypes, host_eval_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!if_exprOperands.empty()) {
|
|
if (parser.resolveOperands(if_exprOperands, odsBuildableType0, if_exprOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(in_reduction_varsOperands, in_reduction_varsTypes, in_reduction_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(is_device_ptr_varsOperands, is_device_ptr_varsTypes, is_device_ptr_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(map_varsOperands, map_varsTypes, map_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(map_iteratedOperands, map_iteratedTypes, map_iteratedOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(private_varsOperands, private_varsTypes, private_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(thread_limit_varsOperands, thread_limit_varsTypes, thread_limit_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TargetOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getAllocateVars().size() || getAllocatorVars().size()) {
|
|
_odsPrinter << ' ' << "allocate";
|
|
_odsPrinter << "(";
|
|
printAllocateAndAllocator(_odsPrinter, *this, getAllocateVars(), getAllocateVars().getTypes(), getAllocatorVars(), getAllocatorVars().getTypes());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getBareAttr() && getBareAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "ompx_bare";
|
|
}
|
|
if (false || getDependVars().size() || (getDependKindsAttr()) || getDependIterated().size() || (getDependIteratedKindsAttr())) {
|
|
_odsPrinter << ' ' << "depend";
|
|
_odsPrinter << "(";
|
|
printDependVarList(_odsPrinter, *this, getDependVars(), getDependVars().getTypes(), getDependKindsAttr(), getDependIterated(), getDependIterated().getTypes(), getDependIteratedKindsAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getDevice()) {
|
|
_odsPrinter << ' ' << "device";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getDevice())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << (getDevice() ? ::llvm::ArrayRef<::mlir::Type>(getDevice().getType()) : ::llvm::ArrayRef<::mlir::Type>());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getDynGroupprivateAccessGroupAttr()) || (getDynGroupprivateFallbackAttr()) || getDynGroupprivateSize()) {
|
|
_odsPrinter << ' ' << "dyn_groupprivate";
|
|
_odsPrinter << "(";
|
|
printDynGroupprivateClause(_odsPrinter, *this, getDynGroupprivateAccessGroupAttr(), getDynGroupprivateFallbackAttr(), getDynGroupprivateSize(), (getDynGroupprivateSize() ? getDynGroupprivateSize().getType() : ::mlir::Type()));
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getIfExpr()) {
|
|
_odsPrinter << ' ' << "if";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getIfExpr())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getIsDevicePtrVars().size()) {
|
|
_odsPrinter << ' ' << "is_device_ptr";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getIsDevicePtrVars();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getIsDevicePtrVars().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getNowaitAttr() && getNowaitAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "nowait";
|
|
}
|
|
if (false || getThreadLimitVars().size()) {
|
|
_odsPrinter << ' ' << "thread_limit";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getThreadLimitVars();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getThreadLimitVars().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
if (!getMapIterated().empty()) {
|
|
_odsPrinter << ' ' << "map_iterated";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getMapIterated();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getMapIterated().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ';
|
|
printTargetOpRegion(_odsPrinter, *this, getRegion(), getHasDeviceAddrVars(), getHasDeviceAddrVars().getTypes(), getHostEvalVars(), getHostEvalVars().getTypes(), getInReductionVars(), getInReductionVars().getTypes(), getInReductionByrefAttr(), getInReductionSymsAttr(), getMapVars(), getMapVars().getTypes(), getPrivateVars(), getPrivateVars().getTypes(), getPrivateSymsAttr(), getPrivateNeedsBarrierAttr(), getPrivateMapsAttr());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("bare");
|
|
elidedAttrs.push_back("depend_kinds");
|
|
elidedAttrs.push_back("depend_iterated_kinds");
|
|
elidedAttrs.push_back("dyn_groupprivate_access_group");
|
|
elidedAttrs.push_back("dyn_groupprivate_fallback");
|
|
elidedAttrs.push_back("nowait");
|
|
elidedAttrs.push_back("in_reduction_byref");
|
|
elidedAttrs.push_back("in_reduction_syms");
|
|
elidedAttrs.push_back("private_syms");
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
elidedAttrs.push_back("private_maps");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getBareAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("bare");
|
|
}
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getNowaitAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("nowait");
|
|
}
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getPrivateNeedsBarrierAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::TargetOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::TargetOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::TargetUpdateOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TargetUpdateOpGenericAdaptorBase::TargetUpdateOpGenericAdaptorBase(TargetUpdateOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> TargetUpdateOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetUpdateOpGenericAdaptorBase::getDependKinds() {
|
|
auto attr = getDependKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetUpdateOpGenericAdaptorBase::getDependIteratedKinds() {
|
|
auto attr = getDependIteratedKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr TargetUpdateOpGenericAdaptorBase::getNowaitAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nowait);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool TargetUpdateOpGenericAdaptorBase::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
TargetUpdateOpAdaptor::TargetUpdateOpAdaptor(TargetUpdateOp op) : TargetUpdateOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TargetUpdateOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_depend_iterated_kinds = getProperties().depend_iterated_kinds; (void)tblgen_depend_iterated_kinds;
|
|
auto tblgen_depend_kinds = getProperties().depend_kinds; (void)tblgen_depend_kinds;
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
|
|
if (tblgen_depend_kinds && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_depend_kinds))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_depend_kinds), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::omp::ClauseTaskDependAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.target_update' op attribute 'depend_kinds' failed to satisfy constraint: depend clause in a target or task construct array");
|
|
|
|
if (tblgen_depend_iterated_kinds && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_depend_iterated_kinds))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_depend_iterated_kinds), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::omp::ClauseTaskDependAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.target_update' op attribute 'depend_iterated_kinds' failed to satisfy constraint: depend clause in a target or task construct array");
|
|
|
|
if (tblgen_nowait && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nowait))))
|
|
return emitError(loc, "'omp.target_update' op attribute 'nowait' failed to satisfy constraint: unit attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> TargetUpdateOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange TargetUpdateOp::getDependVarsMutable() {
|
|
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 TargetUpdateOp::getDependIteratedMutable() {
|
|
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 TargetUpdateOp::getDeviceMutable() {
|
|
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 TargetUpdateOp::getIfExprMutable() {
|
|
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 TargetUpdateOp::getMapVarsMutable() {
|
|
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 TargetUpdateOp::getMapIteratedMutable() {
|
|
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;
|
|
}
|
|
|
|
::llvm::LogicalResult TargetUpdateOp::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.depend_iterated_kinds;
|
|
auto attr = dict.get("depend_iterated_kinds");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `depend_iterated_kinds` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.depend_kinds;
|
|
auto attr = dict.get("depend_kinds");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `depend_kinds` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.nowait;
|
|
auto attr = dict.get("nowait");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nowait` 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 TargetUpdateOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.depend_iterated_kinds;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("depend_iterated_kinds",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.depend_kinds;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("depend_kinds",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.nowait;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nowait",
|
|
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 TargetUpdateOp::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.depend_iterated_kinds.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.depend_kinds.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.nowait.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TargetUpdateOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "depend_iterated_kinds")
|
|
return prop.depend_iterated_kinds;
|
|
|
|
if (name == "depend_kinds")
|
|
return prop.depend_kinds;
|
|
|
|
if (name == "nowait")
|
|
return prop.nowait;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TargetUpdateOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "depend_iterated_kinds") {
|
|
prop.depend_iterated_kinds = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.depend_iterated_kinds)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "depend_kinds") {
|
|
prop.depend_kinds = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.depend_kinds)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "nowait") {
|
|
prop.nowait = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nowait)>>(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 TargetUpdateOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.depend_iterated_kinds) attrs.append("depend_iterated_kinds", prop.depend_iterated_kinds);
|
|
|
|
if (prop.depend_kinds) attrs.append("depend_kinds", prop.depend_kinds);
|
|
|
|
if (prop.nowait) attrs.append("nowait", prop.nowait);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult TargetUpdateOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDependIteratedKindsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(attr, "depend_iterated_kinds", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDependKindsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(attr, "depend_kinds", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNowaitAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "nowait", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TargetUpdateOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.depend_iterated_kinds)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.depend_kinds)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nowait)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(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 TargetUpdateOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.depend_iterated_kinds);
|
|
|
|
writer.writeOptionalAttribute(prop.depend_kinds);
|
|
|
|
writer.writeOptionalAttribute(prop.nowait);
|
|
|
|
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 > TargetUpdateOp::getDependKinds() {
|
|
auto attr = getDependKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TargetUpdateOp::getDependIteratedKinds() {
|
|
auto attr = getDependIteratedKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool TargetUpdateOp::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
void TargetUpdateOp::setNowait(bool attrValue) {
|
|
auto &odsProp = getProperties().nowait;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
TargetUpdateOp TargetUpdateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const TargetEnterExitUpdateDataOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<TargetUpdateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetUpdateOp TargetUpdateOp::create(::mlir::ImplicitLocOpBuilder &builder, const TargetEnterExitUpdateDataOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void TargetUpdateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (device ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
}
|
|
|
|
TargetUpdateOp TargetUpdateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<TargetUpdateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetUpdateOp TargetUpdateOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void TargetUpdateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (device ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetUpdateOp TargetUpdateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<TargetUpdateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetUpdateOp TargetUpdateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void TargetUpdateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (device ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
}
|
|
|
|
TargetUpdateOp TargetUpdateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<TargetUpdateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetUpdateOp TargetUpdateOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void TargetUpdateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (device)
|
|
odsState.addOperands(device);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(map_vars);
|
|
odsState.addOperands(map_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (device ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(map_vars.size()), static_cast<int32_t>(map_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetUpdateOp TargetUpdateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<TargetUpdateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetUpdateOp TargetUpdateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value device, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange map_vars, ::mlir::ValueRange map_iterated, /*optional*/bool nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(device)>(device), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(map_vars)>(map_vars), std::forward<decltype(map_iterated)>(map_iterated), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void TargetUpdateOp::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<TargetUpdateOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
TargetUpdateOp TargetUpdateOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<TargetUpdateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetUpdateOp TargetUpdateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void TargetUpdateOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TargetUpdateOp TargetUpdateOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<TargetUpdateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TargetUpdateOp TargetUpdateOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult TargetUpdateOp::verifyInvariantsImpl() {
|
|
auto tblgen_depend_iterated_kinds = getProperties().depend_iterated_kinds; (void)tblgen_depend_iterated_kinds;
|
|
auto tblgen_depend_kinds = getProperties().depend_kinds; (void)tblgen_depend_kinds;
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(*this, tblgen_depend_kinds, "depend_kinds")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(*this, tblgen_depend_iterated_kinds, "depend_iterated_kinds")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_nowait, "nowait")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps11(*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_OpenMPOps6(*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_OpenMPOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup4 = getODSOperands(4);
|
|
|
|
for (auto v : valueGroup4) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup5 = getODSOperands(5);
|
|
|
|
for (auto v : valueGroup5) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps11(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TargetUpdateOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult TargetUpdateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> depend_varsOperands;
|
|
::llvm::SMLoc depend_varsOperandsLoc;
|
|
(void)depend_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> depend_varsTypes;
|
|
::mlir::ArrayAttr depend_kindsAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> depend_iteratedOperands;
|
|
::llvm::SMLoc depend_iteratedOperandsLoc;
|
|
(void)depend_iteratedOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> depend_iteratedTypes;
|
|
::mlir::ArrayAttr depend_iterated_kindsAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> deviceOperands;
|
|
::llvm::SMLoc deviceOperandsLoc;
|
|
(void)deviceOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> deviceTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> if_exprOperands;
|
|
::llvm::SMLoc if_exprOperandsLoc;
|
|
(void)if_exprOperandsLoc;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> map_varsOperands;
|
|
::llvm::SMLoc map_varsOperandsLoc;
|
|
(void)map_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> map_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> map_iteratedOperands;
|
|
::llvm::SMLoc map_iteratedOperandsLoc;
|
|
(void)map_iteratedOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> map_iteratedTypes;
|
|
bool dependClause = false;
|
|
bool deviceClause = false;
|
|
bool ifClause = false;
|
|
bool map_entriesClause = false;
|
|
bool map_iteratedClause = false;
|
|
bool nowaitClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("depend"))) {
|
|
|
|
if (dependClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`depend` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
dependClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
depend_varsOperandsLoc = parser.getCurrentLocation();
|
|
depend_iteratedOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseDependVarList(parser, depend_varsOperands, depend_varsTypes, depend_kindsAttr, depend_iteratedOperands, depend_iteratedTypes, depend_iterated_kindsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (depend_kindsAttr)
|
|
result.getOrAddProperties<TargetUpdateOp::Properties>().depend_kinds = depend_kindsAttr;
|
|
if (depend_iterated_kindsAttr)
|
|
result.getOrAddProperties<TargetUpdateOp::Properties>().depend_iterated_kinds = depend_iterated_kindsAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("device"))) {
|
|
|
|
if (deviceClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`device` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
deviceClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
deviceOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
deviceOperands.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();
|
|
deviceTypes.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();
|
|
|
|
{
|
|
if_exprOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
if_exprOperands.push_back(operand);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("map_entries"))) {
|
|
|
|
if (map_entriesClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`map_entries` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
map_entriesClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
map_varsOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(map_varsOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(map_varsTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("map_iterated"))) {
|
|
|
|
if (map_iteratedClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`map_iterated` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
map_iteratedClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
map_iteratedOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(map_iteratedOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(map_iteratedTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("nowait"))) {
|
|
|
|
if (nowaitClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`nowait` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
nowaitClause = true;
|
|
result.getOrAddProperties<TargetUpdateOp::Properties>().nowait = parser.getBuilder().getUnitAttr(); } 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<int32_t>({static_cast<int32_t>(depend_varsOperands.size()), static_cast<int32_t>(depend_iteratedOperands.size()), static_cast<int32_t>(deviceOperands.size()), static_cast<int32_t>(if_exprOperands.size()), static_cast<int32_t>(map_varsOperands.size()), static_cast<int32_t>(map_iteratedOperands.size())}), result.getOrAddProperties<TargetUpdateOp::Properties>().operandSegmentSizes.begin());
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1);
|
|
if (parser.resolveOperands(depend_varsOperands, depend_varsTypes, depend_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(depend_iteratedOperands, depend_iteratedTypes, depend_iteratedOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!deviceOperands.empty()) {
|
|
if (parser.resolveOperands(deviceOperands, deviceTypes, deviceOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (!if_exprOperands.empty()) {
|
|
if (parser.resolveOperands(if_exprOperands, odsBuildableType0, if_exprOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(map_varsOperands, map_varsTypes, map_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(map_iteratedOperands, map_iteratedTypes, map_iteratedOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TargetUpdateOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getDependVars().size() || (getDependKindsAttr()) || getDependIterated().size() || (getDependIteratedKindsAttr())) {
|
|
_odsPrinter << ' ' << "depend";
|
|
_odsPrinter << "(";
|
|
printDependVarList(_odsPrinter, *this, getDependVars(), getDependVars().getTypes(), getDependKindsAttr(), getDependIterated(), getDependIterated().getTypes(), getDependIteratedKindsAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getDevice()) {
|
|
_odsPrinter << ' ' << "device";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getDevice())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << (getDevice() ? ::llvm::ArrayRef<::mlir::Type>(getDevice().getType()) : ::llvm::ArrayRef<::mlir::Type>());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getIfExpr()) {
|
|
_odsPrinter << ' ' << "if";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getIfExpr())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getMapVars().size()) {
|
|
_odsPrinter << ' ' << "map_entries";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getMapVars();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getMapVars().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getMapIterated().size()) {
|
|
_odsPrinter << ' ' << "map_iterated";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getMapIterated();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getMapIterated().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getNowaitAttr() && getNowaitAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "nowait";
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("depend_kinds");
|
|
elidedAttrs.push_back("depend_iterated_kinds");
|
|
elidedAttrs.push_back("nowait");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getNowaitAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("nowait");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::TargetUpdateOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::TargetUpdateOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::TaskOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TaskOpGenericAdaptorBase::TaskOpGenericAdaptorBase(TaskOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> TaskOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskOpGenericAdaptorBase::getDependKinds() {
|
|
auto attr = getDependKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskOpGenericAdaptorBase::getDependIteratedKinds() {
|
|
auto attr = getDependIteratedKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> TaskOpGenericAdaptorBase::getInReductionByref() {
|
|
auto attr = getInReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskOpGenericAdaptorBase::getInReductionSyms() {
|
|
auto attr = getInReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr TaskOpGenericAdaptorBase::getMergeableAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().mergeable);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool TaskOpGenericAdaptorBase::getMergeable() {
|
|
auto attr = getMergeableAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskOpGenericAdaptorBase::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr TaskOpGenericAdaptorBase::getPrivateNeedsBarrierAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().private_needs_barrier);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool TaskOpGenericAdaptorBase::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::mlir::UnitAttr TaskOpGenericAdaptorBase::getUntiedAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().untied);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool TaskOpGenericAdaptorBase::getUntied() {
|
|
auto attr = getUntiedAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
TaskOpAdaptor::TaskOpAdaptor(TaskOp op) : TaskOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TaskOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_depend_iterated_kinds = getProperties().depend_iterated_kinds; (void)tblgen_depend_iterated_kinds;
|
|
auto tblgen_depend_kinds = getProperties().depend_kinds; (void)tblgen_depend_kinds;
|
|
auto tblgen_in_reduction_byref = getProperties().in_reduction_byref; (void)tblgen_in_reduction_byref;
|
|
auto tblgen_in_reduction_syms = getProperties().in_reduction_syms; (void)tblgen_in_reduction_syms;
|
|
auto tblgen_mergeable = getProperties().mergeable; (void)tblgen_mergeable;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_untied = getProperties().untied; (void)tblgen_untied;
|
|
|
|
if (tblgen_depend_kinds && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_depend_kinds))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_depend_kinds), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::omp::ClauseTaskDependAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.task' op attribute 'depend_kinds' failed to satisfy constraint: depend clause in a target or task construct array");
|
|
|
|
if (tblgen_depend_iterated_kinds && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_depend_iterated_kinds))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_depend_iterated_kinds), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::omp::ClauseTaskDependAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.task' op attribute 'depend_iterated_kinds' failed to satisfy constraint: depend clause in a target or task construct array");
|
|
|
|
if (tblgen_in_reduction_byref && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(tblgen_in_reduction_byref))))
|
|
return emitError(loc, "'omp.task' op attribute 'in_reduction_byref' failed to satisfy constraint: i1 dense array attribute");
|
|
|
|
if (tblgen_in_reduction_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_in_reduction_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_in_reduction_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.task' op attribute 'in_reduction_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_mergeable && !((::llvm::isa<::mlir::UnitAttr>(tblgen_mergeable))))
|
|
return emitError(loc, "'omp.task' op attribute 'mergeable' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_private_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_private_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_private_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.task' op attribute 'private_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_private_needs_barrier && !((::llvm::isa<::mlir::UnitAttr>(tblgen_private_needs_barrier))))
|
|
return emitError(loc, "'omp.task' op attribute 'private_needs_barrier' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_untied && !((::llvm::isa<::mlir::UnitAttr>(tblgen_untied))))
|
|
return emitError(loc, "'omp.task' op attribute 'untied' failed to satisfy constraint: unit attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> TaskOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange TaskOp::getIteratedMutable() {
|
|
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 TaskOp::getAffinityVarsMutable() {
|
|
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 TaskOp::getAllocateVarsMutable() {
|
|
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 TaskOp::getAllocatorVarsMutable() {
|
|
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 TaskOp::getDependVarsMutable() {
|
|
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 TaskOp::getDependIteratedMutable() {
|
|
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 TaskOp::getFinalMutable() {
|
|
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 TaskOp::getIfExprMutable() {
|
|
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 TaskOp::getInReductionVarsMutable() {
|
|
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 TaskOp::getPriorityMutable() {
|
|
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 TaskOp::getPrivateVarsMutable() {
|
|
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;
|
|
}
|
|
|
|
::mlir::MutableOperandRange TaskOp::getEventHandleMutable() {
|
|
auto range = getODSOperandIndexAndLength(11);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(11u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)}));
|
|
return mutableRange;
|
|
}
|
|
|
|
::llvm::LogicalResult TaskOp::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.depend_iterated_kinds;
|
|
auto attr = dict.get("depend_iterated_kinds");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `depend_iterated_kinds` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.depend_kinds;
|
|
auto attr = dict.get("depend_kinds");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `depend_kinds` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.in_reduction_byref;
|
|
auto attr = dict.get("in_reduction_byref");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `in_reduction_byref` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.in_reduction_syms;
|
|
auto attr = dict.get("in_reduction_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `in_reduction_syms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.mergeable;
|
|
auto attr = dict.get("mergeable");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `mergeable` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_needs_barrier;
|
|
auto attr = dict.get("private_needs_barrier");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_needs_barrier` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_syms;
|
|
auto attr = dict.get("private_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_syms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.untied;
|
|
auto attr = dict.get("untied");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `untied` 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 TaskOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.depend_iterated_kinds;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("depend_iterated_kinds",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.depend_kinds;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("depend_kinds",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.in_reduction_byref;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("in_reduction_byref",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.in_reduction_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("in_reduction_syms",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.mergeable;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("mergeable",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_needs_barrier;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_needs_barrier",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_syms",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.untied;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("untied",
|
|
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 TaskOp::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.depend_iterated_kinds.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.depend_kinds.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.in_reduction_byref.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.in_reduction_syms.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.mergeable.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_needs_barrier.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_syms.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.untied.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TaskOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "depend_iterated_kinds")
|
|
return prop.depend_iterated_kinds;
|
|
|
|
if (name == "depend_kinds")
|
|
return prop.depend_kinds;
|
|
|
|
if (name == "in_reduction_byref")
|
|
return prop.in_reduction_byref;
|
|
|
|
if (name == "in_reduction_syms")
|
|
return prop.in_reduction_syms;
|
|
|
|
if (name == "mergeable")
|
|
return prop.mergeable;
|
|
|
|
if (name == "private_needs_barrier")
|
|
return prop.private_needs_barrier;
|
|
|
|
if (name == "private_syms")
|
|
return prop.private_syms;
|
|
|
|
if (name == "untied")
|
|
return prop.untied;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TaskOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "depend_iterated_kinds") {
|
|
prop.depend_iterated_kinds = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.depend_iterated_kinds)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "depend_kinds") {
|
|
prop.depend_kinds = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.depend_kinds)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "in_reduction_byref") {
|
|
prop.in_reduction_byref = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.in_reduction_byref)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "in_reduction_syms") {
|
|
prop.in_reduction_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.in_reduction_syms)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "mergeable") {
|
|
prop.mergeable = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.mergeable)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_needs_barrier") {
|
|
prop.private_needs_barrier = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_needs_barrier)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_syms") {
|
|
prop.private_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_syms)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "untied") {
|
|
prop.untied = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.untied)>>(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 TaskOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.depend_iterated_kinds) attrs.append("depend_iterated_kinds", prop.depend_iterated_kinds);
|
|
|
|
if (prop.depend_kinds) attrs.append("depend_kinds", prop.depend_kinds);
|
|
|
|
if (prop.in_reduction_byref) attrs.append("in_reduction_byref", prop.in_reduction_byref);
|
|
|
|
if (prop.in_reduction_syms) attrs.append("in_reduction_syms", prop.in_reduction_syms);
|
|
|
|
if (prop.mergeable) attrs.append("mergeable", prop.mergeable);
|
|
|
|
if (prop.private_needs_barrier) attrs.append("private_needs_barrier", prop.private_needs_barrier);
|
|
|
|
if (prop.private_syms) attrs.append("private_syms", prop.private_syms);
|
|
|
|
if (prop.untied) attrs.append("untied", prop.untied);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult TaskOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDependIteratedKindsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(attr, "depend_iterated_kinds", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDependKindsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(attr, "depend_kinds", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getInReductionByrefAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(attr, "in_reduction_byref", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getInReductionSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "in_reduction_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMergeableAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "mergeable", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateNeedsBarrierAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "private_needs_barrier", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "private_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getUntiedAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "untied", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TaskOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.depend_iterated_kinds)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.depend_kinds)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.in_reduction_byref)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.in_reduction_syms)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.mergeable)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_needs_barrier)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_syms)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.untied)))
|
|
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 TaskOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.depend_iterated_kinds);
|
|
|
|
writer.writeOptionalAttribute(prop.depend_kinds);
|
|
|
|
writer.writeOptionalAttribute(prop.in_reduction_byref);
|
|
|
|
writer.writeOptionalAttribute(prop.in_reduction_syms);
|
|
|
|
writer.writeOptionalAttribute(prop.mergeable);
|
|
|
|
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
|
|
}
|
|
|
|
writer.writeOptionalAttribute(prop.private_needs_barrier);
|
|
|
|
writer.writeOptionalAttribute(prop.private_syms);
|
|
|
|
writer.writeOptionalAttribute(prop.untied);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskOp::getDependKinds() {
|
|
auto attr = getDependKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskOp::getDependIteratedKinds() {
|
|
auto attr = getDependIteratedKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> TaskOp::getInReductionByref() {
|
|
auto attr = getInReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskOp::getInReductionSyms() {
|
|
auto attr = getInReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool TaskOp::getMergeable() {
|
|
auto attr = getMergeableAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskOp::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool TaskOp::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
bool TaskOp::getUntied() {
|
|
auto attr = getUntiedAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
void TaskOp::setInReductionByref(::std::optional<::llvm::ArrayRef<bool>> attrValue) {
|
|
auto &odsProp = getProperties().in_reduction_byref;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getDenseBoolArrayAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TaskOp::setMergeable(bool attrValue) {
|
|
auto &odsProp = getProperties().mergeable;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TaskOp::setPrivateNeedsBarrier(bool attrValue) {
|
|
auto &odsProp = getProperties().private_needs_barrier;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TaskOp::setUntied(bool attrValue) {
|
|
auto &odsProp = getProperties().untied;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
TaskOp TaskOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const TaskOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<TaskOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskOp TaskOp::create(::mlir::ImplicitLocOpBuilder &builder, const TaskOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void TaskOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange iterated, ::mlir::ValueRange affinity_vars, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value final, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/::mlir::UnitAttr mergeable, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::UnitAttr untied, /*optional*/::mlir::Value event_handle) {
|
|
odsState.addOperands(iterated);
|
|
odsState.addOperands(affinity_vars);
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (final)
|
|
odsState.addOperands(final);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(in_reduction_vars);
|
|
if (priority)
|
|
odsState.addOperands(priority);
|
|
odsState.addOperands(private_vars);
|
|
if (event_handle)
|
|
odsState.addOperands(event_handle);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(iterated.size()), static_cast<int32_t>(affinity_vars.size()), static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (final ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(in_reduction_vars.size()), (priority ? 1 : 0), static_cast<int32_t>(private_vars.size()), (event_handle ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (in_reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_byref = in_reduction_byref;
|
|
}
|
|
if (in_reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_syms = in_reduction_syms;
|
|
}
|
|
if (mergeable) {
|
|
odsState.getOrAddProperties<Properties>().mergeable = mergeable;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (untied) {
|
|
odsState.getOrAddProperties<Properties>().untied = untied;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
TaskOp TaskOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange iterated, ::mlir::ValueRange affinity_vars, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value final, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/::mlir::UnitAttr mergeable, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::UnitAttr untied, /*optional*/::mlir::Value event_handle) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(iterated)>(iterated), std::forward<decltype(affinity_vars)>(affinity_vars), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(final)>(final), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(mergeable)>(mergeable), std::forward<decltype(priority)>(priority), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(untied)>(untied), std::forward<decltype(event_handle)>(event_handle));
|
|
auto __res__ = ::llvm::dyn_cast<TaskOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskOp TaskOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange iterated, ::mlir::ValueRange affinity_vars, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value final, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/::mlir::UnitAttr mergeable, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::UnitAttr untied, /*optional*/::mlir::Value event_handle) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(iterated)>(iterated), std::forward<decltype(affinity_vars)>(affinity_vars), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(final)>(final), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(mergeable)>(mergeable), std::forward<decltype(priority)>(priority), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(untied)>(untied), std::forward<decltype(event_handle)>(event_handle));
|
|
}
|
|
|
|
void TaskOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange iterated, ::mlir::ValueRange affinity_vars, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value final, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/::mlir::UnitAttr mergeable, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::UnitAttr untied, /*optional*/::mlir::Value event_handle) {
|
|
odsState.addOperands(iterated);
|
|
odsState.addOperands(affinity_vars);
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (final)
|
|
odsState.addOperands(final);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(in_reduction_vars);
|
|
if (priority)
|
|
odsState.addOperands(priority);
|
|
odsState.addOperands(private_vars);
|
|
if (event_handle)
|
|
odsState.addOperands(event_handle);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(iterated.size()), static_cast<int32_t>(affinity_vars.size()), static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (final ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(in_reduction_vars.size()), (priority ? 1 : 0), static_cast<int32_t>(private_vars.size()), (event_handle ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (in_reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_byref = in_reduction_byref;
|
|
}
|
|
if (in_reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_syms = in_reduction_syms;
|
|
}
|
|
if (mergeable) {
|
|
odsState.getOrAddProperties<Properties>().mergeable = mergeable;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (untied) {
|
|
odsState.getOrAddProperties<Properties>().untied = untied;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TaskOp TaskOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange iterated, ::mlir::ValueRange affinity_vars, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value final, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/::mlir::UnitAttr mergeable, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::UnitAttr untied, /*optional*/::mlir::Value event_handle) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(iterated)>(iterated), std::forward<decltype(affinity_vars)>(affinity_vars), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(final)>(final), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(mergeable)>(mergeable), std::forward<decltype(priority)>(priority), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(untied)>(untied), std::forward<decltype(event_handle)>(event_handle));
|
|
auto __res__ = ::llvm::dyn_cast<TaskOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskOp TaskOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange iterated, ::mlir::ValueRange affinity_vars, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value final, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/::mlir::UnitAttr mergeable, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::UnitAttr untied, /*optional*/::mlir::Value event_handle) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(iterated)>(iterated), std::forward<decltype(affinity_vars)>(affinity_vars), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(final)>(final), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(mergeable)>(mergeable), std::forward<decltype(priority)>(priority), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(untied)>(untied), std::forward<decltype(event_handle)>(event_handle));
|
|
}
|
|
|
|
void TaskOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange iterated, ::mlir::ValueRange affinity_vars, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value final, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/bool mergeable, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/bool untied, /*optional*/::mlir::Value event_handle) {
|
|
odsState.addOperands(iterated);
|
|
odsState.addOperands(affinity_vars);
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (final)
|
|
odsState.addOperands(final);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(in_reduction_vars);
|
|
if (priority)
|
|
odsState.addOperands(priority);
|
|
odsState.addOperands(private_vars);
|
|
if (event_handle)
|
|
odsState.addOperands(event_handle);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(iterated.size()), static_cast<int32_t>(affinity_vars.size()), static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (final ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(in_reduction_vars.size()), (priority ? 1 : 0), static_cast<int32_t>(private_vars.size()), (event_handle ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (in_reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_byref = in_reduction_byref;
|
|
}
|
|
if (in_reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_syms = in_reduction_syms;
|
|
}
|
|
if (mergeable) {
|
|
odsState.getOrAddProperties<Properties>().mergeable = ((mergeable) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (untied) {
|
|
odsState.getOrAddProperties<Properties>().untied = ((untied) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
TaskOp TaskOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange iterated, ::mlir::ValueRange affinity_vars, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value final, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/bool mergeable, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/bool untied, /*optional*/::mlir::Value event_handle) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(iterated)>(iterated), std::forward<decltype(affinity_vars)>(affinity_vars), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(final)>(final), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(mergeable)>(mergeable), std::forward<decltype(priority)>(priority), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(untied)>(untied), std::forward<decltype(event_handle)>(event_handle));
|
|
auto __res__ = ::llvm::dyn_cast<TaskOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskOp TaskOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange iterated, ::mlir::ValueRange affinity_vars, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value final, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/bool mergeable, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/bool untied, /*optional*/::mlir::Value event_handle) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(iterated)>(iterated), std::forward<decltype(affinity_vars)>(affinity_vars), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(final)>(final), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(mergeable)>(mergeable), std::forward<decltype(priority)>(priority), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(untied)>(untied), std::forward<decltype(event_handle)>(event_handle));
|
|
}
|
|
|
|
void TaskOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange iterated, ::mlir::ValueRange affinity_vars, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value final, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/bool mergeable, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/bool untied, /*optional*/::mlir::Value event_handle) {
|
|
odsState.addOperands(iterated);
|
|
odsState.addOperands(affinity_vars);
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
if (final)
|
|
odsState.addOperands(final);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(in_reduction_vars);
|
|
if (priority)
|
|
odsState.addOperands(priority);
|
|
odsState.addOperands(private_vars);
|
|
if (event_handle)
|
|
odsState.addOperands(event_handle);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(iterated.size()), static_cast<int32_t>(affinity_vars.size()), static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size()), (final ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(in_reduction_vars.size()), (priority ? 1 : 0), static_cast<int32_t>(private_vars.size()), (event_handle ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (in_reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_byref = in_reduction_byref;
|
|
}
|
|
if (in_reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_syms = in_reduction_syms;
|
|
}
|
|
if (mergeable) {
|
|
odsState.getOrAddProperties<Properties>().mergeable = ((mergeable) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (untied) {
|
|
odsState.getOrAddProperties<Properties>().untied = ((untied) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TaskOp TaskOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange iterated, ::mlir::ValueRange affinity_vars, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value final, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/bool mergeable, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/bool untied, /*optional*/::mlir::Value event_handle) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(iterated)>(iterated), std::forward<decltype(affinity_vars)>(affinity_vars), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(final)>(final), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(mergeable)>(mergeable), std::forward<decltype(priority)>(priority), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(untied)>(untied), std::forward<decltype(event_handle)>(event_handle));
|
|
auto __res__ = ::llvm::dyn_cast<TaskOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskOp TaskOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange iterated, ::mlir::ValueRange affinity_vars, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::Value final, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/bool mergeable, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/bool untied, /*optional*/::mlir::Value event_handle) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(iterated)>(iterated), std::forward<decltype(affinity_vars)>(affinity_vars), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(final)>(final), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(mergeable)>(mergeable), std::forward<decltype(priority)>(priority), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(untied)>(untied), std::forward<decltype(event_handle)>(event_handle));
|
|
}
|
|
|
|
void TaskOp::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<TaskOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
TaskOp TaskOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<TaskOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskOp TaskOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void TaskOp::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&>(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);
|
|
}
|
|
|
|
TaskOp TaskOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<TaskOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskOp TaskOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult TaskOp::verifyInvariantsImpl() {
|
|
auto tblgen_depend_iterated_kinds = getProperties().depend_iterated_kinds; (void)tblgen_depend_iterated_kinds;
|
|
auto tblgen_depend_kinds = getProperties().depend_kinds; (void)tblgen_depend_kinds;
|
|
auto tblgen_in_reduction_byref = getProperties().in_reduction_byref; (void)tblgen_in_reduction_byref;
|
|
auto tblgen_in_reduction_syms = getProperties().in_reduction_syms; (void)tblgen_in_reduction_syms;
|
|
auto tblgen_mergeable = getProperties().mergeable; (void)tblgen_mergeable;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_untied = getProperties().untied; (void)tblgen_untied;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(*this, tblgen_depend_kinds, "depend_kinds")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(*this, tblgen_depend_iterated_kinds, "depend_iterated_kinds")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(*this, tblgen_in_reduction_byref, "in_reduction_byref")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_in_reduction_syms, "in_reduction_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_mergeable, "mergeable")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_private_syms, "private_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_private_needs_barrier, "private_needs_barrier")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_untied, "untied")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps11(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps19(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup4 = getODSOperands(4);
|
|
|
|
for (auto v : valueGroup4) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup5 = getODSOperands(5);
|
|
|
|
for (auto v : valueGroup5) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps11(*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_OpenMPOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup7 = getODSOperands(7);
|
|
|
|
if (valueGroup7.size() > 1) {
|
|
return emitOpError("operand group starting at #") << index
|
|
<< " requires 0 or 1 element, but found " << valueGroup7.size();
|
|
}
|
|
|
|
for (auto v : valueGroup7) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup8 = getODSOperands(8);
|
|
|
|
for (auto v : valueGroup8) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup9 = getODSOperands(9);
|
|
|
|
if (valueGroup9.size() > 1) {
|
|
return emitOpError("operand group starting at #") << index
|
|
<< " requires 0 or 1 element, but found " << valueGroup9.size();
|
|
}
|
|
|
|
for (auto v : valueGroup9) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup10 = getODSOperands(10);
|
|
|
|
for (auto v : valueGroup10) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup11 = getODSOperands(11);
|
|
|
|
if (valueGroup11.size() > 1) {
|
|
return emitOpError("operand group starting at #") << index
|
|
<< " requires 0 or 1 element, but found " << valueGroup11.size();
|
|
}
|
|
|
|
for (auto v : valueGroup11) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps1(*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_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TaskOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult TaskOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> iteratedOperands;
|
|
::llvm::SMLoc iteratedOperandsLoc;
|
|
(void)iteratedOperandsLoc;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> affinity_varsOperands;
|
|
::llvm::SMLoc affinity_varsOperandsLoc;
|
|
(void)affinity_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> iteratedTypes;
|
|
::llvm::SmallVector<::mlir::Type, 1> affinity_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocate_varsOperands;
|
|
::llvm::SMLoc allocate_varsOperandsLoc;
|
|
(void)allocate_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocate_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocator_varsOperands;
|
|
::llvm::SMLoc allocator_varsOperandsLoc;
|
|
(void)allocator_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocator_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> depend_varsOperands;
|
|
::llvm::SMLoc depend_varsOperandsLoc;
|
|
(void)depend_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> depend_varsTypes;
|
|
::mlir::ArrayAttr depend_kindsAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> depend_iteratedOperands;
|
|
::llvm::SMLoc depend_iteratedOperandsLoc;
|
|
(void)depend_iteratedOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> depend_iteratedTypes;
|
|
::mlir::ArrayAttr depend_iterated_kindsAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> finalOperands;
|
|
::llvm::SMLoc finalOperandsLoc;
|
|
(void)finalOperandsLoc;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> if_exprOperands;
|
|
::llvm::SMLoc if_exprOperandsLoc;
|
|
(void)if_exprOperandsLoc;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> priorityOperands;
|
|
::llvm::SMLoc priorityOperandsLoc;
|
|
(void)priorityOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> priorityTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> event_handleOperands;
|
|
::llvm::SMLoc event_handleOperandsLoc;
|
|
(void)event_handleOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> event_handleTypes;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> in_reduction_varsOperands;
|
|
::llvm::SMLoc in_reduction_varsOperandsLoc;
|
|
(void)in_reduction_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> in_reduction_varsTypes;
|
|
::mlir::DenseBoolArrayAttr in_reduction_byrefAttr;
|
|
::mlir::ArrayAttr in_reduction_symsAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> private_varsOperands;
|
|
::llvm::SMLoc private_varsOperandsLoc;
|
|
(void)private_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> private_varsTypes;
|
|
::mlir::ArrayAttr private_symsAttr;
|
|
::mlir::UnitAttr private_needs_barrierAttr;
|
|
bool affinityClause = false;
|
|
bool allocateClause = false;
|
|
bool dependClause = false;
|
|
bool finalClause = false;
|
|
bool ifClause = false;
|
|
bool mergeableClause = false;
|
|
bool priorityClause = false;
|
|
bool untiedClause = false;
|
|
bool detachClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("affinity"))) {
|
|
|
|
if (affinityClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`affinity` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
affinityClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
iteratedOperandsLoc = parser.getCurrentLocation();
|
|
affinity_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseAffinityClause(parser, iteratedOperands, affinity_varsOperands, iteratedTypes, affinity_varsTypes);
|
|
if (odsResult) return ::mlir::failure();
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("allocate"))) {
|
|
|
|
if (allocateClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`allocate` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
allocateClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
allocate_varsOperandsLoc = parser.getCurrentLocation();
|
|
allocator_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseAllocateAndAllocator(parser, allocate_varsOperands, allocate_varsTypes, allocator_varsOperands, allocator_varsTypes);
|
|
if (odsResult) return ::mlir::failure();
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("depend"))) {
|
|
|
|
if (dependClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`depend` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
dependClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
depend_varsOperandsLoc = parser.getCurrentLocation();
|
|
depend_iteratedOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseDependVarList(parser, depend_varsOperands, depend_varsTypes, depend_kindsAttr, depend_iteratedOperands, depend_iteratedTypes, depend_iterated_kindsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (depend_kindsAttr)
|
|
result.getOrAddProperties<TaskOp::Properties>().depend_kinds = depend_kindsAttr;
|
|
if (depend_iterated_kindsAttr)
|
|
result.getOrAddProperties<TaskOp::Properties>().depend_iterated_kinds = depend_iterated_kindsAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("final"))) {
|
|
|
|
if (finalClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`final` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
finalClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
finalOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
finalOperands.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();
|
|
|
|
{
|
|
if_exprOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
if_exprOperands.push_back(operand);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("mergeable"))) {
|
|
|
|
if (mergeableClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`mergeable` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
mergeableClause = true;
|
|
result.getOrAddProperties<TaskOp::Properties>().mergeable = parser.getBuilder().getUnitAttr(); } else if (succeeded(parser.parseOptionalKeyword("priority"))) {
|
|
|
|
if (priorityClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`priority` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
priorityClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
priorityOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
priorityOperands.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();
|
|
priorityTypes.push_back(optionalType);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("untied"))) {
|
|
|
|
if (untiedClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`untied` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
untiedClause = true;
|
|
result.getOrAddProperties<TaskOp::Properties>().untied = parser.getBuilder().getUnitAttr(); } else if (succeeded(parser.parseOptionalKeyword("detach"))) {
|
|
|
|
if (detachClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`detach` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
detachClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
event_handleOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
event_handleOperands.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();
|
|
event_handleTypes.push_back(optionalType);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
{
|
|
in_reduction_varsOperandsLoc = parser.getCurrentLocation();
|
|
private_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseInReductionPrivateRegion(parser, *regionRegion, in_reduction_varsOperands, in_reduction_varsTypes, in_reduction_byrefAttr, in_reduction_symsAttr, private_varsOperands, private_varsTypes, private_symsAttr, private_needs_barrierAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (in_reduction_byrefAttr)
|
|
result.getOrAddProperties<TaskOp::Properties>().in_reduction_byref = in_reduction_byrefAttr;
|
|
if (in_reduction_symsAttr)
|
|
result.getOrAddProperties<TaskOp::Properties>().in_reduction_syms = in_reduction_symsAttr;
|
|
if (private_symsAttr)
|
|
result.getOrAddProperties<TaskOp::Properties>().private_syms = private_symsAttr;
|
|
if (private_needs_barrierAttr)
|
|
result.getOrAddProperties<TaskOp::Properties>().private_needs_barrier = private_needs_barrierAttr;
|
|
}
|
|
{
|
|
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<int32_t>({static_cast<int32_t>(iteratedOperands.size()), static_cast<int32_t>(affinity_varsOperands.size()), static_cast<int32_t>(allocate_varsOperands.size()), static_cast<int32_t>(allocator_varsOperands.size()), static_cast<int32_t>(depend_varsOperands.size()), static_cast<int32_t>(depend_iteratedOperands.size()), static_cast<int32_t>(finalOperands.size()), static_cast<int32_t>(if_exprOperands.size()), static_cast<int32_t>(in_reduction_varsOperands.size()), static_cast<int32_t>(priorityOperands.size()), static_cast<int32_t>(private_varsOperands.size()), static_cast<int32_t>(event_handleOperands.size())}), result.getOrAddProperties<TaskOp::Properties>().operandSegmentSizes.begin());
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1);
|
|
if (parser.resolveOperands(iteratedOperands, iteratedTypes, iteratedOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(affinity_varsOperands, affinity_varsTypes, affinity_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(allocate_varsOperands, allocate_varsTypes, allocate_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(allocator_varsOperands, allocator_varsTypes, allocator_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(depend_varsOperands, depend_varsTypes, depend_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(depend_iteratedOperands, depend_iteratedTypes, depend_iteratedOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!finalOperands.empty()) {
|
|
if (parser.resolveOperands(finalOperands, odsBuildableType0, finalOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (!if_exprOperands.empty()) {
|
|
if (parser.resolveOperands(if_exprOperands, odsBuildableType0, if_exprOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(in_reduction_varsOperands, in_reduction_varsTypes, in_reduction_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!priorityOperands.empty()) {
|
|
if (parser.resolveOperands(priorityOperands, priorityTypes, priorityOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(private_varsOperands, private_varsTypes, private_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!event_handleOperands.empty()) {
|
|
if (parser.resolveOperands(event_handleOperands, event_handleTypes, event_handleOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TaskOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getIterated().size() || getAffinityVars().size()) {
|
|
_odsPrinter << ' ' << "affinity";
|
|
_odsPrinter << "(";
|
|
printAffinityClause(_odsPrinter, *this, getIterated(), getAffinityVars(), getIterated().getTypes(), getAffinityVars().getTypes());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getAllocateVars().size() || getAllocatorVars().size()) {
|
|
_odsPrinter << ' ' << "allocate";
|
|
_odsPrinter << "(";
|
|
printAllocateAndAllocator(_odsPrinter, *this, getAllocateVars(), getAllocateVars().getTypes(), getAllocatorVars(), getAllocatorVars().getTypes());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getDependVars().size() || (getDependKindsAttr()) || getDependIterated().size() || (getDependIteratedKindsAttr())) {
|
|
_odsPrinter << ' ' << "depend";
|
|
_odsPrinter << "(";
|
|
printDependVarList(_odsPrinter, *this, getDependVars(), getDependVars().getTypes(), getDependKindsAttr(), getDependIterated(), getDependIterated().getTypes(), getDependIteratedKindsAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getFinal()) {
|
|
_odsPrinter << ' ' << "final";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getFinal())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getIfExpr()) {
|
|
_odsPrinter << ' ' << "if";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getIfExpr())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getMergeableAttr() && getMergeableAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "mergeable";
|
|
}
|
|
if (false || getPriority()) {
|
|
_odsPrinter << ' ' << "priority";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getPriority())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << (getPriority() ? ::llvm::ArrayRef<::mlir::Type>(getPriority().getType()) : ::llvm::ArrayRef<::mlir::Type>());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getUntiedAttr() && getUntiedAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "untied";
|
|
}
|
|
if (false || getEventHandle()) {
|
|
_odsPrinter << ' ' << "detach";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getEventHandle())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << (getEventHandle() ? ::llvm::ArrayRef<::mlir::Type>(getEventHandle().getType()) : ::llvm::ArrayRef<::mlir::Type>());
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ';
|
|
printInReductionPrivateRegion(_odsPrinter, *this, getRegion(), getInReductionVars(), getInReductionVars().getTypes(), getInReductionByrefAttr(), getInReductionSymsAttr(), getPrivateVars(), getPrivateVars().getTypes(), getPrivateSymsAttr(), getPrivateNeedsBarrierAttr());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("depend_kinds");
|
|
elidedAttrs.push_back("depend_iterated_kinds");
|
|
elidedAttrs.push_back("mergeable");
|
|
elidedAttrs.push_back("untied");
|
|
elidedAttrs.push_back("in_reduction_byref");
|
|
elidedAttrs.push_back("in_reduction_syms");
|
|
elidedAttrs.push_back("private_syms");
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getMergeableAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("mergeable");
|
|
}
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getPrivateNeedsBarrierAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
}
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getUntiedAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("untied");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::TaskOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::TaskOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::TaskgroupOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TaskgroupOpGenericAdaptorBase::TaskgroupOpGenericAdaptorBase(TaskgroupOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> TaskgroupOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> TaskgroupOpGenericAdaptorBase::getTaskReductionByref() {
|
|
auto attr = getTaskReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskgroupOpGenericAdaptorBase::getTaskReductionSyms() {
|
|
auto attr = getTaskReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
TaskgroupOpAdaptor::TaskgroupOpAdaptor(TaskgroupOp op) : TaskgroupOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TaskgroupOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_task_reduction_byref = getProperties().task_reduction_byref; (void)tblgen_task_reduction_byref;
|
|
auto tblgen_task_reduction_syms = getProperties().task_reduction_syms; (void)tblgen_task_reduction_syms;
|
|
|
|
if (tblgen_task_reduction_byref && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(tblgen_task_reduction_byref))))
|
|
return emitError(loc, "'omp.taskgroup' op attribute 'task_reduction_byref' failed to satisfy constraint: i1 dense array attribute");
|
|
|
|
if (tblgen_task_reduction_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_task_reduction_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_task_reduction_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.taskgroup' op attribute 'task_reduction_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> TaskgroupOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange TaskgroupOp::getAllocateVarsMutable() {
|
|
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 TaskgroupOp::getAllocatorVarsMutable() {
|
|
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 TaskgroupOp::getTaskReductionVarsMutable() {
|
|
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 TaskgroupOp::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.task_reduction_byref;
|
|
auto attr = dict.get("task_reduction_byref");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `task_reduction_byref` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.task_reduction_syms;
|
|
auto attr = dict.get("task_reduction_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `task_reduction_syms` 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 TaskgroupOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.task_reduction_byref;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("task_reduction_byref",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.task_reduction_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("task_reduction_syms",
|
|
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 TaskgroupOp::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.task_reduction_byref.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.task_reduction_syms.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TaskgroupOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "task_reduction_byref")
|
|
return prop.task_reduction_byref;
|
|
|
|
if (name == "task_reduction_syms")
|
|
return prop.task_reduction_syms;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TaskgroupOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "task_reduction_byref") {
|
|
prop.task_reduction_byref = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.task_reduction_byref)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "task_reduction_syms") {
|
|
prop.task_reduction_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.task_reduction_syms)>>(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 TaskgroupOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.task_reduction_byref) attrs.append("task_reduction_byref", prop.task_reduction_byref);
|
|
|
|
if (prop.task_reduction_syms) attrs.append("task_reduction_syms", prop.task_reduction_syms);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult TaskgroupOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getTaskReductionByrefAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(attr, "task_reduction_byref", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getTaskReductionSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "task_reduction_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TaskgroupOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.task_reduction_byref)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.task_reduction_syms)))
|
|
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 TaskgroupOp::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.task_reduction_byref);
|
|
|
|
writer.writeOptionalAttribute(prop.task_reduction_syms);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> TaskgroupOp::getTaskReductionByref() {
|
|
auto attr = getTaskReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskgroupOp::getTaskReductionSyms() {
|
|
auto attr = getTaskReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
void TaskgroupOp::setTaskReductionByref(::std::optional<::llvm::ArrayRef<bool>> attrValue) {
|
|
auto &odsProp = getProperties().task_reduction_byref;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getDenseBoolArrayAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
TaskgroupOp TaskgroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const TaskgroupOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<TaskgroupOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskgroupOp TaskgroupOp::create(::mlir::ImplicitLocOpBuilder &builder, const TaskgroupOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void TaskgroupOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange task_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr task_reduction_byref, /*optional*/::mlir::ArrayAttr task_reduction_syms) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(task_reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(task_reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (task_reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().task_reduction_byref = task_reduction_byref;
|
|
}
|
|
if (task_reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().task_reduction_syms = task_reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
TaskgroupOp TaskgroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange task_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr task_reduction_byref, /*optional*/::mlir::ArrayAttr task_reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(task_reduction_vars)>(task_reduction_vars), std::forward<decltype(task_reduction_byref)>(task_reduction_byref), std::forward<decltype(task_reduction_syms)>(task_reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<TaskgroupOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskgroupOp TaskgroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange task_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr task_reduction_byref, /*optional*/::mlir::ArrayAttr task_reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(task_reduction_vars)>(task_reduction_vars), std::forward<decltype(task_reduction_byref)>(task_reduction_byref), std::forward<decltype(task_reduction_syms)>(task_reduction_syms));
|
|
}
|
|
|
|
void TaskgroupOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange task_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr task_reduction_byref, /*optional*/::mlir::ArrayAttr task_reduction_syms) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(task_reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(task_reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (task_reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().task_reduction_byref = task_reduction_byref;
|
|
}
|
|
if (task_reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().task_reduction_syms = task_reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TaskgroupOp TaskgroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange task_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr task_reduction_byref, /*optional*/::mlir::ArrayAttr task_reduction_syms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(task_reduction_vars)>(task_reduction_vars), std::forward<decltype(task_reduction_byref)>(task_reduction_byref), std::forward<decltype(task_reduction_syms)>(task_reduction_syms));
|
|
auto __res__ = ::llvm::dyn_cast<TaskgroupOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskgroupOp TaskgroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange task_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr task_reduction_byref, /*optional*/::mlir::ArrayAttr task_reduction_syms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(task_reduction_vars)>(task_reduction_vars), std::forward<decltype(task_reduction_byref)>(task_reduction_byref), std::forward<decltype(task_reduction_syms)>(task_reduction_syms));
|
|
}
|
|
|
|
void TaskgroupOp::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<TaskgroupOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
TaskgroupOp TaskgroupOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<TaskgroupOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskgroupOp TaskgroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void TaskgroupOp::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&>(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);
|
|
}
|
|
|
|
TaskgroupOp TaskgroupOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<TaskgroupOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskgroupOp TaskgroupOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult TaskgroupOp::verifyInvariantsImpl() {
|
|
auto tblgen_task_reduction_byref = getProperties().task_reduction_byref; (void)tblgen_task_reduction_byref;
|
|
auto tblgen_task_reduction_syms = getProperties().task_reduction_syms; (void)tblgen_task_reduction_syms;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(*this, tblgen_task_reduction_byref, "task_reduction_byref")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_task_reduction_syms, "task_reduction_syms")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*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_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TaskgroupOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult TaskgroupOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocate_varsOperands;
|
|
::llvm::SMLoc allocate_varsOperandsLoc;
|
|
(void)allocate_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocate_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocator_varsOperands;
|
|
::llvm::SMLoc allocator_varsOperandsLoc;
|
|
(void)allocator_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocator_varsTypes;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> task_reduction_varsOperands;
|
|
::llvm::SMLoc task_reduction_varsOperandsLoc;
|
|
(void)task_reduction_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> task_reduction_varsTypes;
|
|
::mlir::DenseBoolArrayAttr task_reduction_byrefAttr;
|
|
::mlir::ArrayAttr task_reduction_symsAttr;
|
|
bool allocateClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("allocate"))) {
|
|
|
|
if (allocateClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`allocate` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
allocateClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
allocate_varsOperandsLoc = parser.getCurrentLocation();
|
|
allocator_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseAllocateAndAllocator(parser, allocate_varsOperands, allocate_varsTypes, allocator_varsOperands, allocator_varsTypes);
|
|
if (odsResult) return ::mlir::failure();
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
{
|
|
task_reduction_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseTaskReductionRegion(parser, *regionRegion, task_reduction_varsOperands, task_reduction_varsTypes, task_reduction_byrefAttr, task_reduction_symsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (task_reduction_byrefAttr)
|
|
result.getOrAddProperties<TaskgroupOp::Properties>().task_reduction_byref = task_reduction_byrefAttr;
|
|
if (task_reduction_symsAttr)
|
|
result.getOrAddProperties<TaskgroupOp::Properties>().task_reduction_syms = task_reduction_symsAttr;
|
|
}
|
|
{
|
|
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<int32_t>({static_cast<int32_t>(allocate_varsOperands.size()), static_cast<int32_t>(allocator_varsOperands.size()), static_cast<int32_t>(task_reduction_varsOperands.size())}), result.getOrAddProperties<TaskgroupOp::Properties>().operandSegmentSizes.begin());
|
|
if (parser.resolveOperands(allocate_varsOperands, allocate_varsTypes, allocate_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(allocator_varsOperands, allocator_varsTypes, allocator_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(task_reduction_varsOperands, task_reduction_varsTypes, task_reduction_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TaskgroupOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getAllocateVars().size() || getAllocatorVars().size()) {
|
|
_odsPrinter << ' ' << "allocate";
|
|
_odsPrinter << "(";
|
|
printAllocateAndAllocator(_odsPrinter, *this, getAllocateVars(), getAllocateVars().getTypes(), getAllocatorVars(), getAllocatorVars().getTypes());
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ';
|
|
printTaskReductionRegion(_odsPrinter, *this, getRegion(), getTaskReductionVars(), getTaskReductionVars().getTypes(), getTaskReductionByrefAttr(), getTaskReductionSymsAttr());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("task_reduction_byref");
|
|
elidedAttrs.push_back("task_reduction_syms");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::TaskgroupOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::TaskgroupOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::TaskloopContextOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TaskloopContextOpGenericAdaptorBase::TaskloopContextOpGenericAdaptorBase(TaskloopContextOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> TaskloopContextOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseGrainsizeType> TaskloopContextOpGenericAdaptorBase::getGrainsizeMod() {
|
|
auto attr = getGrainsizeModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseGrainsizeType>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> TaskloopContextOpGenericAdaptorBase::getInReductionByref() {
|
|
auto attr = getInReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskloopContextOpGenericAdaptorBase::getInReductionSyms() {
|
|
auto attr = getInReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr TaskloopContextOpGenericAdaptorBase::getMergeableAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().mergeable);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool TaskloopContextOpGenericAdaptorBase::getMergeable() {
|
|
auto attr = getMergeableAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::mlir::UnitAttr TaskloopContextOpGenericAdaptorBase::getNogroupAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nogroup);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool TaskloopContextOpGenericAdaptorBase::getNogroup() {
|
|
auto attr = getNogroupAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseNumTasksType> TaskloopContextOpGenericAdaptorBase::getNumTasksMod() {
|
|
auto attr = getNumTasksModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseNumTasksType>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskloopContextOpGenericAdaptorBase::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr TaskloopContextOpGenericAdaptorBase::getPrivateNeedsBarrierAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().private_needs_barrier);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool TaskloopContextOpGenericAdaptorBase::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ReductionModifier> TaskloopContextOpGenericAdaptorBase::getReductionMod() {
|
|
auto attr = getReductionModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ReductionModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> TaskloopContextOpGenericAdaptorBase::getReductionByref() {
|
|
auto attr = getReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskloopContextOpGenericAdaptorBase::getReductionSyms() {
|
|
auto attr = getReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr TaskloopContextOpGenericAdaptorBase::getUntiedAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().untied);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool TaskloopContextOpGenericAdaptorBase::getUntied() {
|
|
auto attr = getUntiedAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
TaskloopContextOpAdaptor::TaskloopContextOpAdaptor(TaskloopContextOp op) : TaskloopContextOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TaskloopContextOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_grainsize_mod = getProperties().grainsize_mod; (void)tblgen_grainsize_mod;
|
|
auto tblgen_in_reduction_byref = getProperties().in_reduction_byref; (void)tblgen_in_reduction_byref;
|
|
auto tblgen_in_reduction_syms = getProperties().in_reduction_syms; (void)tblgen_in_reduction_syms;
|
|
auto tblgen_mergeable = getProperties().mergeable; (void)tblgen_mergeable;
|
|
auto tblgen_nogroup = getProperties().nogroup; (void)tblgen_nogroup;
|
|
auto tblgen_num_tasks_mod = getProperties().num_tasks_mod; (void)tblgen_num_tasks_mod;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_reduction_byref = getProperties().reduction_byref; (void)tblgen_reduction_byref;
|
|
auto tblgen_reduction_mod = getProperties().reduction_mod; (void)tblgen_reduction_mod;
|
|
auto tblgen_reduction_syms = getProperties().reduction_syms; (void)tblgen_reduction_syms;
|
|
auto tblgen_untied = getProperties().untied; (void)tblgen_untied;
|
|
|
|
if (tblgen_grainsize_mod && !((::llvm::isa<::mlir::omp::ClauseGrainsizeTypeAttr>(tblgen_grainsize_mod))))
|
|
return emitError(loc, "'omp.taskloop.context' op attribute 'grainsize_mod' failed to satisfy constraint: GrainsizeType Clause");
|
|
|
|
if (tblgen_in_reduction_byref && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(tblgen_in_reduction_byref))))
|
|
return emitError(loc, "'omp.taskloop.context' op attribute 'in_reduction_byref' failed to satisfy constraint: i1 dense array attribute");
|
|
|
|
if (tblgen_in_reduction_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_in_reduction_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_in_reduction_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.taskloop.context' op attribute 'in_reduction_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_mergeable && !((::llvm::isa<::mlir::UnitAttr>(tblgen_mergeable))))
|
|
return emitError(loc, "'omp.taskloop.context' op attribute 'mergeable' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_nogroup && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nogroup))))
|
|
return emitError(loc, "'omp.taskloop.context' op attribute 'nogroup' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_num_tasks_mod && !((::llvm::isa<::mlir::omp::ClauseNumTasksTypeAttr>(tblgen_num_tasks_mod))))
|
|
return emitError(loc, "'omp.taskloop.context' op attribute 'num_tasks_mod' failed to satisfy constraint: NumTasksType Clause");
|
|
|
|
if (tblgen_private_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_private_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_private_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.taskloop.context' op attribute 'private_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_private_needs_barrier && !((::llvm::isa<::mlir::UnitAttr>(tblgen_private_needs_barrier))))
|
|
return emitError(loc, "'omp.taskloop.context' op attribute 'private_needs_barrier' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_reduction_mod && !((::llvm::isa<::mlir::omp::ReductionModifierAttr>(tblgen_reduction_mod))))
|
|
return emitError(loc, "'omp.taskloop.context' op attribute 'reduction_mod' failed to satisfy constraint: reduction modifier");
|
|
|
|
if (tblgen_reduction_byref && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(tblgen_reduction_byref))))
|
|
return emitError(loc, "'omp.taskloop.context' op attribute 'reduction_byref' failed to satisfy constraint: i1 dense array attribute");
|
|
|
|
if (tblgen_reduction_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_reduction_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_reduction_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.taskloop.context' op attribute 'reduction_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_untied && !((::llvm::isa<::mlir::UnitAttr>(tblgen_untied))))
|
|
return emitError(loc, "'omp.taskloop.context' op attribute 'untied' failed to satisfy constraint: unit attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> TaskloopContextOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange TaskloopContextOp::getAllocateVarsMutable() {
|
|
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 TaskloopContextOp::getAllocatorVarsMutable() {
|
|
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 TaskloopContextOp::getFinalMutable() {
|
|
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 TaskloopContextOp::getGrainsizeMutable() {
|
|
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 TaskloopContextOp::getIfExprMutable() {
|
|
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 TaskloopContextOp::getInReductionVarsMutable() {
|
|
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 TaskloopContextOp::getNumTasksMutable() {
|
|
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 TaskloopContextOp::getPriorityMutable() {
|
|
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 TaskloopContextOp::getPrivateVarsMutable() {
|
|
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 TaskloopContextOp::getReductionVarsMutable() {
|
|
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;
|
|
}
|
|
|
|
::llvm::LogicalResult TaskloopContextOp::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.grainsize_mod;
|
|
auto attr = dict.get("grainsize_mod");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `grainsize_mod` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.in_reduction_byref;
|
|
auto attr = dict.get("in_reduction_byref");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `in_reduction_byref` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.in_reduction_syms;
|
|
auto attr = dict.get("in_reduction_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `in_reduction_syms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.mergeable;
|
|
auto attr = dict.get("mergeable");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `mergeable` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.nogroup;
|
|
auto attr = dict.get("nogroup");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nogroup` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.num_tasks_mod;
|
|
auto attr = dict.get("num_tasks_mod");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `num_tasks_mod` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_needs_barrier;
|
|
auto attr = dict.get("private_needs_barrier");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_needs_barrier` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_syms;
|
|
auto attr = dict.get("private_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_syms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_byref;
|
|
auto attr = dict.get("reduction_byref");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_byref` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_mod;
|
|
auto attr = dict.get("reduction_mod");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_mod` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_syms;
|
|
auto attr = dict.get("reduction_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_syms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.untied;
|
|
auto attr = dict.get("untied");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `untied` 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 TaskloopContextOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.grainsize_mod;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("grainsize_mod",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.in_reduction_byref;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("in_reduction_byref",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.in_reduction_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("in_reduction_syms",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.mergeable;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("mergeable",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.nogroup;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nogroup",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.num_tasks_mod;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("num_tasks_mod",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_needs_barrier;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_needs_barrier",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_syms",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_byref;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_byref",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_mod;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_mod",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_syms",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.untied;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("untied",
|
|
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 TaskloopContextOp::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.grainsize_mod.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.in_reduction_byref.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.in_reduction_syms.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.mergeable.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.nogroup.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.num_tasks_mod.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_needs_barrier.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_syms.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_byref.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_mod.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_syms.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.untied.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TaskloopContextOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "grainsize_mod")
|
|
return prop.grainsize_mod;
|
|
|
|
if (name == "in_reduction_byref")
|
|
return prop.in_reduction_byref;
|
|
|
|
if (name == "in_reduction_syms")
|
|
return prop.in_reduction_syms;
|
|
|
|
if (name == "mergeable")
|
|
return prop.mergeable;
|
|
|
|
if (name == "nogroup")
|
|
return prop.nogroup;
|
|
|
|
if (name == "num_tasks_mod")
|
|
return prop.num_tasks_mod;
|
|
|
|
if (name == "private_needs_barrier")
|
|
return prop.private_needs_barrier;
|
|
|
|
if (name == "private_syms")
|
|
return prop.private_syms;
|
|
|
|
if (name == "reduction_byref")
|
|
return prop.reduction_byref;
|
|
|
|
if (name == "reduction_mod")
|
|
return prop.reduction_mod;
|
|
|
|
if (name == "reduction_syms")
|
|
return prop.reduction_syms;
|
|
|
|
if (name == "untied")
|
|
return prop.untied;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TaskloopContextOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "grainsize_mod") {
|
|
prop.grainsize_mod = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.grainsize_mod)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "in_reduction_byref") {
|
|
prop.in_reduction_byref = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.in_reduction_byref)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "in_reduction_syms") {
|
|
prop.in_reduction_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.in_reduction_syms)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "mergeable") {
|
|
prop.mergeable = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.mergeable)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "nogroup") {
|
|
prop.nogroup = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nogroup)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "num_tasks_mod") {
|
|
prop.num_tasks_mod = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.num_tasks_mod)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_needs_barrier") {
|
|
prop.private_needs_barrier = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_needs_barrier)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_syms") {
|
|
prop.private_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_syms)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_byref") {
|
|
prop.reduction_byref = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_byref)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_mod") {
|
|
prop.reduction_mod = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_mod)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_syms") {
|
|
prop.reduction_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_syms)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "untied") {
|
|
prop.untied = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.untied)>>(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 TaskloopContextOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.grainsize_mod) attrs.append("grainsize_mod", prop.grainsize_mod);
|
|
|
|
if (prop.in_reduction_byref) attrs.append("in_reduction_byref", prop.in_reduction_byref);
|
|
|
|
if (prop.in_reduction_syms) attrs.append("in_reduction_syms", prop.in_reduction_syms);
|
|
|
|
if (prop.mergeable) attrs.append("mergeable", prop.mergeable);
|
|
|
|
if (prop.nogroup) attrs.append("nogroup", prop.nogroup);
|
|
|
|
if (prop.num_tasks_mod) attrs.append("num_tasks_mod", prop.num_tasks_mod);
|
|
|
|
if (prop.private_needs_barrier) attrs.append("private_needs_barrier", prop.private_needs_barrier);
|
|
|
|
if (prop.private_syms) attrs.append("private_syms", prop.private_syms);
|
|
|
|
if (prop.reduction_byref) attrs.append("reduction_byref", prop.reduction_byref);
|
|
|
|
if (prop.reduction_mod) attrs.append("reduction_mod", prop.reduction_mod);
|
|
|
|
if (prop.reduction_syms) attrs.append("reduction_syms", prop.reduction_syms);
|
|
|
|
if (prop.untied) attrs.append("untied", prop.untied);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult TaskloopContextOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getGrainsizeModAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps33(attr, "grainsize_mod", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getInReductionByrefAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(attr, "in_reduction_byref", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getInReductionSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "in_reduction_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMergeableAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "mergeable", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNogroupAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "nogroup", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNumTasksModAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps34(attr, "num_tasks_mod", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateNeedsBarrierAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "private_needs_barrier", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "private_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionByrefAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(attr, "reduction_byref", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionModAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps19(attr, "reduction_mod", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "reduction_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getUntiedAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "untied", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TaskloopContextOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.grainsize_mod)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.in_reduction_byref)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.in_reduction_syms)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.mergeable)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nogroup)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.num_tasks_mod)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_needs_barrier)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_syms)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_byref)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_mod)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_syms)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.untied)))
|
|
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 TaskloopContextOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.grainsize_mod);
|
|
|
|
writer.writeOptionalAttribute(prop.in_reduction_byref);
|
|
|
|
writer.writeOptionalAttribute(prop.in_reduction_syms);
|
|
|
|
writer.writeOptionalAttribute(prop.mergeable);
|
|
|
|
writer.writeOptionalAttribute(prop.nogroup);
|
|
|
|
writer.writeOptionalAttribute(prop.num_tasks_mod);
|
|
|
|
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
|
|
}
|
|
|
|
writer.writeOptionalAttribute(prop.private_needs_barrier);
|
|
|
|
writer.writeOptionalAttribute(prop.private_syms);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_byref);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_mod);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_syms);
|
|
|
|
writer.writeOptionalAttribute(prop.untied);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseGrainsizeType> TaskloopContextOp::getGrainsizeMod() {
|
|
auto attr = getGrainsizeModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseGrainsizeType>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> TaskloopContextOp::getInReductionByref() {
|
|
auto attr = getInReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskloopContextOp::getInReductionSyms() {
|
|
auto attr = getInReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool TaskloopContextOp::getMergeable() {
|
|
auto attr = getMergeableAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
bool TaskloopContextOp::getNogroup() {
|
|
auto attr = getNogroupAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseNumTasksType> TaskloopContextOp::getNumTasksMod() {
|
|
auto attr = getNumTasksModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseNumTasksType>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskloopContextOp::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool TaskloopContextOp::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ReductionModifier> TaskloopContextOp::getReductionMod() {
|
|
auto attr = getReductionModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ReductionModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> TaskloopContextOp::getReductionByref() {
|
|
auto attr = getReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskloopContextOp::getReductionSyms() {
|
|
auto attr = getReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool TaskloopContextOp::getUntied() {
|
|
auto attr = getUntiedAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
void TaskloopContextOp::setGrainsizeMod(::std::optional<::mlir::omp::ClauseGrainsizeType> attrValue) {
|
|
auto &odsProp = getProperties().grainsize_mod;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ClauseGrainsizeTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TaskloopContextOp::setInReductionByref(::std::optional<::llvm::ArrayRef<bool>> attrValue) {
|
|
auto &odsProp = getProperties().in_reduction_byref;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getDenseBoolArrayAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TaskloopContextOp::setMergeable(bool attrValue) {
|
|
auto &odsProp = getProperties().mergeable;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TaskloopContextOp::setNogroup(bool attrValue) {
|
|
auto &odsProp = getProperties().nogroup;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TaskloopContextOp::setNumTasksMod(::std::optional<::mlir::omp::ClauseNumTasksType> attrValue) {
|
|
auto &odsProp = getProperties().num_tasks_mod;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ClauseNumTasksTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TaskloopContextOp::setPrivateNeedsBarrier(bool attrValue) {
|
|
auto &odsProp = getProperties().private_needs_barrier;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TaskloopContextOp::setReductionMod(::std::optional<::mlir::omp::ReductionModifier> attrValue) {
|
|
auto &odsProp = getProperties().reduction_mod;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ReductionModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TaskloopContextOp::setReductionByref(::std::optional<::llvm::ArrayRef<bool>> attrValue) {
|
|
auto &odsProp = getProperties().reduction_byref;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getDenseBoolArrayAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TaskloopContextOp::setUntied(bool attrValue) {
|
|
auto &odsProp = getProperties().untied;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
TaskloopContextOp TaskloopContextOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const TaskloopContextOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<TaskloopContextOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskloopContextOp TaskloopContextOp::create(::mlir::ImplicitLocOpBuilder &builder, const TaskloopContextOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void TaskloopContextOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value final, /*optional*/::mlir::omp::ClauseGrainsizeTypeAttr grainsize_mod, /*optional*/::mlir::Value grainsize, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/::mlir::UnitAttr mergeable, /*optional*/::mlir::UnitAttr nogroup, /*optional*/::mlir::omp::ClauseNumTasksTypeAttr num_tasks_mod, /*optional*/::mlir::Value num_tasks, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::UnitAttr untied) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
if (final)
|
|
odsState.addOperands(final);
|
|
if (grainsize)
|
|
odsState.addOperands(grainsize);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(in_reduction_vars);
|
|
if (num_tasks)
|
|
odsState.addOperands(num_tasks);
|
|
if (priority)
|
|
odsState.addOperands(priority);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), (final ? 1 : 0), (grainsize ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(in_reduction_vars.size()), (num_tasks ? 1 : 0), (priority ? 1 : 0), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (grainsize_mod) {
|
|
odsState.getOrAddProperties<Properties>().grainsize_mod = grainsize_mod;
|
|
}
|
|
if (in_reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_byref = in_reduction_byref;
|
|
}
|
|
if (in_reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_syms = in_reduction_syms;
|
|
}
|
|
if (mergeable) {
|
|
odsState.getOrAddProperties<Properties>().mergeable = mergeable;
|
|
}
|
|
if (nogroup) {
|
|
odsState.getOrAddProperties<Properties>().nogroup = nogroup;
|
|
}
|
|
if (num_tasks_mod) {
|
|
odsState.getOrAddProperties<Properties>().num_tasks_mod = num_tasks_mod;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
if (untied) {
|
|
odsState.getOrAddProperties<Properties>().untied = untied;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
TaskloopContextOp TaskloopContextOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value final, /*optional*/::mlir::omp::ClauseGrainsizeTypeAttr grainsize_mod, /*optional*/::mlir::Value grainsize, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/::mlir::UnitAttr mergeable, /*optional*/::mlir::UnitAttr nogroup, /*optional*/::mlir::omp::ClauseNumTasksTypeAttr num_tasks_mod, /*optional*/::mlir::Value num_tasks, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::UnitAttr untied) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(final)>(final), std::forward<decltype(grainsize_mod)>(grainsize_mod), std::forward<decltype(grainsize)>(grainsize), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(mergeable)>(mergeable), std::forward<decltype(nogroup)>(nogroup), std::forward<decltype(num_tasks_mod)>(num_tasks_mod), std::forward<decltype(num_tasks)>(num_tasks), std::forward<decltype(priority)>(priority), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(untied)>(untied));
|
|
auto __res__ = ::llvm::dyn_cast<TaskloopContextOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskloopContextOp TaskloopContextOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value final, /*optional*/::mlir::omp::ClauseGrainsizeTypeAttr grainsize_mod, /*optional*/::mlir::Value grainsize, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/::mlir::UnitAttr mergeable, /*optional*/::mlir::UnitAttr nogroup, /*optional*/::mlir::omp::ClauseNumTasksTypeAttr num_tasks_mod, /*optional*/::mlir::Value num_tasks, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::UnitAttr untied) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(final)>(final), std::forward<decltype(grainsize_mod)>(grainsize_mod), std::forward<decltype(grainsize)>(grainsize), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(mergeable)>(mergeable), std::forward<decltype(nogroup)>(nogroup), std::forward<decltype(num_tasks_mod)>(num_tasks_mod), std::forward<decltype(num_tasks)>(num_tasks), std::forward<decltype(priority)>(priority), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(untied)>(untied));
|
|
}
|
|
|
|
void TaskloopContextOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value final, /*optional*/::mlir::omp::ClauseGrainsizeTypeAttr grainsize_mod, /*optional*/::mlir::Value grainsize, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/::mlir::UnitAttr mergeable, /*optional*/::mlir::UnitAttr nogroup, /*optional*/::mlir::omp::ClauseNumTasksTypeAttr num_tasks_mod, /*optional*/::mlir::Value num_tasks, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::UnitAttr untied) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
if (final)
|
|
odsState.addOperands(final);
|
|
if (grainsize)
|
|
odsState.addOperands(grainsize);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(in_reduction_vars);
|
|
if (num_tasks)
|
|
odsState.addOperands(num_tasks);
|
|
if (priority)
|
|
odsState.addOperands(priority);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), (final ? 1 : 0), (grainsize ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(in_reduction_vars.size()), (num_tasks ? 1 : 0), (priority ? 1 : 0), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (grainsize_mod) {
|
|
odsState.getOrAddProperties<Properties>().grainsize_mod = grainsize_mod;
|
|
}
|
|
if (in_reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_byref = in_reduction_byref;
|
|
}
|
|
if (in_reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_syms = in_reduction_syms;
|
|
}
|
|
if (mergeable) {
|
|
odsState.getOrAddProperties<Properties>().mergeable = mergeable;
|
|
}
|
|
if (nogroup) {
|
|
odsState.getOrAddProperties<Properties>().nogroup = nogroup;
|
|
}
|
|
if (num_tasks_mod) {
|
|
odsState.getOrAddProperties<Properties>().num_tasks_mod = num_tasks_mod;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
if (untied) {
|
|
odsState.getOrAddProperties<Properties>().untied = untied;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TaskloopContextOp TaskloopContextOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value final, /*optional*/::mlir::omp::ClauseGrainsizeTypeAttr grainsize_mod, /*optional*/::mlir::Value grainsize, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/::mlir::UnitAttr mergeable, /*optional*/::mlir::UnitAttr nogroup, /*optional*/::mlir::omp::ClauseNumTasksTypeAttr num_tasks_mod, /*optional*/::mlir::Value num_tasks, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::UnitAttr untied) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(final)>(final), std::forward<decltype(grainsize_mod)>(grainsize_mod), std::forward<decltype(grainsize)>(grainsize), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(mergeable)>(mergeable), std::forward<decltype(nogroup)>(nogroup), std::forward<decltype(num_tasks_mod)>(num_tasks_mod), std::forward<decltype(num_tasks)>(num_tasks), std::forward<decltype(priority)>(priority), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(untied)>(untied));
|
|
auto __res__ = ::llvm::dyn_cast<TaskloopContextOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskloopContextOp TaskloopContextOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value final, /*optional*/::mlir::omp::ClauseGrainsizeTypeAttr grainsize_mod, /*optional*/::mlir::Value grainsize, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/::mlir::UnitAttr mergeable, /*optional*/::mlir::UnitAttr nogroup, /*optional*/::mlir::omp::ClauseNumTasksTypeAttr num_tasks_mod, /*optional*/::mlir::Value num_tasks, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::UnitAttr untied) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(final)>(final), std::forward<decltype(grainsize_mod)>(grainsize_mod), std::forward<decltype(grainsize)>(grainsize), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(mergeable)>(mergeable), std::forward<decltype(nogroup)>(nogroup), std::forward<decltype(num_tasks_mod)>(num_tasks_mod), std::forward<decltype(num_tasks)>(num_tasks), std::forward<decltype(priority)>(priority), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(untied)>(untied));
|
|
}
|
|
|
|
void TaskloopContextOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value final, /*optional*/::mlir::omp::ClauseGrainsizeTypeAttr grainsize_mod, /*optional*/::mlir::Value grainsize, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/bool mergeable, /*optional*/bool nogroup, /*optional*/::mlir::omp::ClauseNumTasksTypeAttr num_tasks_mod, /*optional*/::mlir::Value num_tasks, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/bool untied) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
if (final)
|
|
odsState.addOperands(final);
|
|
if (grainsize)
|
|
odsState.addOperands(grainsize);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(in_reduction_vars);
|
|
if (num_tasks)
|
|
odsState.addOperands(num_tasks);
|
|
if (priority)
|
|
odsState.addOperands(priority);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), (final ? 1 : 0), (grainsize ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(in_reduction_vars.size()), (num_tasks ? 1 : 0), (priority ? 1 : 0), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (grainsize_mod) {
|
|
odsState.getOrAddProperties<Properties>().grainsize_mod = grainsize_mod;
|
|
}
|
|
if (in_reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_byref = in_reduction_byref;
|
|
}
|
|
if (in_reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_syms = in_reduction_syms;
|
|
}
|
|
if (mergeable) {
|
|
odsState.getOrAddProperties<Properties>().mergeable = ((mergeable) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (nogroup) {
|
|
odsState.getOrAddProperties<Properties>().nogroup = ((nogroup) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (num_tasks_mod) {
|
|
odsState.getOrAddProperties<Properties>().num_tasks_mod = num_tasks_mod;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
if (untied) {
|
|
odsState.getOrAddProperties<Properties>().untied = ((untied) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
TaskloopContextOp TaskloopContextOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value final, /*optional*/::mlir::omp::ClauseGrainsizeTypeAttr grainsize_mod, /*optional*/::mlir::Value grainsize, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/bool mergeable, /*optional*/bool nogroup, /*optional*/::mlir::omp::ClauseNumTasksTypeAttr num_tasks_mod, /*optional*/::mlir::Value num_tasks, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/bool untied) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(final)>(final), std::forward<decltype(grainsize_mod)>(grainsize_mod), std::forward<decltype(grainsize)>(grainsize), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(mergeable)>(mergeable), std::forward<decltype(nogroup)>(nogroup), std::forward<decltype(num_tasks_mod)>(num_tasks_mod), std::forward<decltype(num_tasks)>(num_tasks), std::forward<decltype(priority)>(priority), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(untied)>(untied));
|
|
auto __res__ = ::llvm::dyn_cast<TaskloopContextOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskloopContextOp TaskloopContextOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value final, /*optional*/::mlir::omp::ClauseGrainsizeTypeAttr grainsize_mod, /*optional*/::mlir::Value grainsize, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/bool mergeable, /*optional*/bool nogroup, /*optional*/::mlir::omp::ClauseNumTasksTypeAttr num_tasks_mod, /*optional*/::mlir::Value num_tasks, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/bool untied) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(final)>(final), std::forward<decltype(grainsize_mod)>(grainsize_mod), std::forward<decltype(grainsize)>(grainsize), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(mergeable)>(mergeable), std::forward<decltype(nogroup)>(nogroup), std::forward<decltype(num_tasks_mod)>(num_tasks_mod), std::forward<decltype(num_tasks)>(num_tasks), std::forward<decltype(priority)>(priority), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(untied)>(untied));
|
|
}
|
|
|
|
void TaskloopContextOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value final, /*optional*/::mlir::omp::ClauseGrainsizeTypeAttr grainsize_mod, /*optional*/::mlir::Value grainsize, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/bool mergeable, /*optional*/bool nogroup, /*optional*/::mlir::omp::ClauseNumTasksTypeAttr num_tasks_mod, /*optional*/::mlir::Value num_tasks, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/bool untied) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
if (final)
|
|
odsState.addOperands(final);
|
|
if (grainsize)
|
|
odsState.addOperands(grainsize);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
odsState.addOperands(in_reduction_vars);
|
|
if (num_tasks)
|
|
odsState.addOperands(num_tasks);
|
|
if (priority)
|
|
odsState.addOperands(priority);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), (final ? 1 : 0), (grainsize ? 1 : 0), (if_expr ? 1 : 0), static_cast<int32_t>(in_reduction_vars.size()), (num_tasks ? 1 : 0), (priority ? 1 : 0), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (grainsize_mod) {
|
|
odsState.getOrAddProperties<Properties>().grainsize_mod = grainsize_mod;
|
|
}
|
|
if (in_reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_byref = in_reduction_byref;
|
|
}
|
|
if (in_reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().in_reduction_syms = in_reduction_syms;
|
|
}
|
|
if (mergeable) {
|
|
odsState.getOrAddProperties<Properties>().mergeable = ((mergeable) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (nogroup) {
|
|
odsState.getOrAddProperties<Properties>().nogroup = ((nogroup) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (num_tasks_mod) {
|
|
odsState.getOrAddProperties<Properties>().num_tasks_mod = num_tasks_mod;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
if (untied) {
|
|
odsState.getOrAddProperties<Properties>().untied = ((untied) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TaskloopContextOp TaskloopContextOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value final, /*optional*/::mlir::omp::ClauseGrainsizeTypeAttr grainsize_mod, /*optional*/::mlir::Value grainsize, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/bool mergeable, /*optional*/bool nogroup, /*optional*/::mlir::omp::ClauseNumTasksTypeAttr num_tasks_mod, /*optional*/::mlir::Value num_tasks, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/bool untied) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(final)>(final), std::forward<decltype(grainsize_mod)>(grainsize_mod), std::forward<decltype(grainsize)>(grainsize), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(mergeable)>(mergeable), std::forward<decltype(nogroup)>(nogroup), std::forward<decltype(num_tasks_mod)>(num_tasks_mod), std::forward<decltype(num_tasks)>(num_tasks), std::forward<decltype(priority)>(priority), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(untied)>(untied));
|
|
auto __res__ = ::llvm::dyn_cast<TaskloopContextOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskloopContextOp TaskloopContextOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::Value final, /*optional*/::mlir::omp::ClauseGrainsizeTypeAttr grainsize_mod, /*optional*/::mlir::Value grainsize, /*optional*/::mlir::Value if_expr, ::mlir::ValueRange in_reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr in_reduction_byref, /*optional*/::mlir::ArrayAttr in_reduction_syms, /*optional*/bool mergeable, /*optional*/bool nogroup, /*optional*/::mlir::omp::ClauseNumTasksTypeAttr num_tasks_mod, /*optional*/::mlir::Value num_tasks, /*optional*/::mlir::Value priority, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/bool untied) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(final)>(final), std::forward<decltype(grainsize_mod)>(grainsize_mod), std::forward<decltype(grainsize)>(grainsize), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(in_reduction_vars)>(in_reduction_vars), std::forward<decltype(in_reduction_byref)>(in_reduction_byref), std::forward<decltype(in_reduction_syms)>(in_reduction_syms), std::forward<decltype(mergeable)>(mergeable), std::forward<decltype(nogroup)>(nogroup), std::forward<decltype(num_tasks_mod)>(num_tasks_mod), std::forward<decltype(num_tasks)>(num_tasks), std::forward<decltype(priority)>(priority), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(untied)>(untied));
|
|
}
|
|
|
|
void TaskloopContextOp::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<TaskloopContextOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
TaskloopContextOp TaskloopContextOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<TaskloopContextOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskloopContextOp TaskloopContextOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void TaskloopContextOp::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&>(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);
|
|
}
|
|
|
|
TaskloopContextOp TaskloopContextOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<TaskloopContextOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskloopContextOp TaskloopContextOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult TaskloopContextOp::verifyInvariantsImpl() {
|
|
auto tblgen_grainsize_mod = getProperties().grainsize_mod; (void)tblgen_grainsize_mod;
|
|
auto tblgen_in_reduction_byref = getProperties().in_reduction_byref; (void)tblgen_in_reduction_byref;
|
|
auto tblgen_in_reduction_syms = getProperties().in_reduction_syms; (void)tblgen_in_reduction_syms;
|
|
auto tblgen_mergeable = getProperties().mergeable; (void)tblgen_mergeable;
|
|
auto tblgen_nogroup = getProperties().nogroup; (void)tblgen_nogroup;
|
|
auto tblgen_num_tasks_mod = getProperties().num_tasks_mod; (void)tblgen_num_tasks_mod;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_reduction_byref = getProperties().reduction_byref; (void)tblgen_reduction_byref;
|
|
auto tblgen_reduction_mod = getProperties().reduction_mod; (void)tblgen_reduction_mod;
|
|
auto tblgen_reduction_syms = getProperties().reduction_syms; (void)tblgen_reduction_syms;
|
|
auto tblgen_untied = getProperties().untied; (void)tblgen_untied;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps33(*this, tblgen_grainsize_mod, "grainsize_mod")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(*this, tblgen_in_reduction_byref, "in_reduction_byref")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_in_reduction_syms, "in_reduction_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_mergeable, "mergeable")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_nogroup, "nogroup")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps34(*this, tblgen_num_tasks_mod, "num_tasks_mod")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_private_syms, "private_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_private_needs_barrier, "private_needs_barrier")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps19(*this, tblgen_reduction_mod, "reduction_mod")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(*this, tblgen_reduction_byref, "reduction_byref")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_reduction_syms, "reduction_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_untied, "untied")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*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_OpenMPOps8(*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_OpenMPOps2(*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_OpenMPOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup5 = getODSOperands(5);
|
|
|
|
for (auto v : valueGroup5) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*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_OpenMPOps2(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup7 = getODSOperands(7);
|
|
|
|
if (valueGroup7.size() > 1) {
|
|
return emitOpError("operand group starting at #") << index
|
|
<< " requires 0 or 1 element, but found " << valueGroup7.size();
|
|
}
|
|
|
|
for (auto v : valueGroup7) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup8 = getODSOperands(8);
|
|
|
|
for (auto v : valueGroup8) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup9 = getODSOperands(9);
|
|
|
|
for (auto v : valueGroup9) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*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_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TaskloopContextOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult TaskloopContextOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocate_varsOperands;
|
|
::llvm::SMLoc allocate_varsOperandsLoc;
|
|
(void)allocate_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocate_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocator_varsOperands;
|
|
::llvm::SMLoc allocator_varsOperandsLoc;
|
|
(void)allocator_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocator_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> finalOperands;
|
|
::llvm::SMLoc finalOperandsLoc;
|
|
(void)finalOperandsLoc;
|
|
::mlir::omp::ClauseGrainsizeTypeAttr grainsize_modAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> grainsizeOperands;
|
|
::llvm::SMLoc grainsizeOperandsLoc;
|
|
(void)grainsizeOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> grainsizeTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> if_exprOperands;
|
|
::llvm::SMLoc if_exprOperandsLoc;
|
|
(void)if_exprOperandsLoc;
|
|
::mlir::omp::ClauseNumTasksTypeAttr num_tasks_modAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> num_tasksOperands;
|
|
::llvm::SMLoc num_tasksOperandsLoc;
|
|
(void)num_tasksOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> num_tasksTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> priorityOperands;
|
|
::llvm::SMLoc priorityOperandsLoc;
|
|
(void)priorityOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> priorityTypes;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> in_reduction_varsOperands;
|
|
::llvm::SMLoc in_reduction_varsOperandsLoc;
|
|
(void)in_reduction_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> in_reduction_varsTypes;
|
|
::mlir::DenseBoolArrayAttr in_reduction_byrefAttr;
|
|
::mlir::ArrayAttr in_reduction_symsAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> private_varsOperands;
|
|
::llvm::SMLoc private_varsOperandsLoc;
|
|
(void)private_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> private_varsTypes;
|
|
::mlir::ArrayAttr private_symsAttr;
|
|
::mlir::UnitAttr private_needs_barrierAttr;
|
|
::mlir::omp::ReductionModifierAttr reduction_modAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> reduction_varsOperands;
|
|
::llvm::SMLoc reduction_varsOperandsLoc;
|
|
(void)reduction_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> reduction_varsTypes;
|
|
::mlir::DenseBoolArrayAttr reduction_byrefAttr;
|
|
::mlir::ArrayAttr reduction_symsAttr;
|
|
bool allocateClause = false;
|
|
bool finalClause = false;
|
|
bool grainsizeClause = false;
|
|
bool ifClause = false;
|
|
bool mergeableClause = false;
|
|
bool nogroupClause = false;
|
|
bool num_tasksClause = false;
|
|
bool priorityClause = false;
|
|
bool untiedClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("allocate"))) {
|
|
|
|
if (allocateClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`allocate` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
allocateClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
allocate_varsOperandsLoc = parser.getCurrentLocation();
|
|
allocator_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseAllocateAndAllocator(parser, allocate_varsOperands, allocate_varsTypes, allocator_varsOperands, allocator_varsTypes);
|
|
if (odsResult) return ::mlir::failure();
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("final"))) {
|
|
|
|
if (finalClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`final` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
finalClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
finalOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
finalOperands.push_back(operand);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("grainsize"))) {
|
|
|
|
if (grainsizeClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`grainsize` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
grainsizeClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
grainsizeOperandsLoc = parser.getCurrentLocation();
|
|
::std::optional<::mlir::OpAsmParser::UnresolvedOperand> grainsizeOperand;
|
|
::mlir::Type grainsizeType;
|
|
auto odsResult = parseGrainsizeClause(parser, grainsize_modAttr, grainsizeOperand, grainsizeType);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (grainsize_modAttr)
|
|
result.getOrAddProperties<TaskloopContextOp::Properties>().grainsize_mod = grainsize_modAttr;
|
|
if (grainsizeOperand.has_value())
|
|
grainsizeOperands.push_back(*grainsizeOperand);
|
|
if (grainsizeType)
|
|
grainsizeTypes.push_back(grainsizeType);
|
|
}
|
|
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();
|
|
|
|
{
|
|
if_exprOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
if_exprOperands.push_back(operand);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("mergeable"))) {
|
|
|
|
if (mergeableClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`mergeable` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
mergeableClause = true;
|
|
result.getOrAddProperties<TaskloopContextOp::Properties>().mergeable = parser.getBuilder().getUnitAttr(); } else if (succeeded(parser.parseOptionalKeyword("nogroup"))) {
|
|
|
|
if (nogroupClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`nogroup` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
nogroupClause = true;
|
|
result.getOrAddProperties<TaskloopContextOp::Properties>().nogroup = parser.getBuilder().getUnitAttr(); } else if (succeeded(parser.parseOptionalKeyword("num_tasks"))) {
|
|
|
|
if (num_tasksClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`num_tasks` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
num_tasksClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
num_tasksOperandsLoc = parser.getCurrentLocation();
|
|
::std::optional<::mlir::OpAsmParser::UnresolvedOperand> num_tasksOperand;
|
|
::mlir::Type num_tasksType;
|
|
auto odsResult = parseNumTasksClause(parser, num_tasks_modAttr, num_tasksOperand, num_tasksType);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (num_tasks_modAttr)
|
|
result.getOrAddProperties<TaskloopContextOp::Properties>().num_tasks_mod = num_tasks_modAttr;
|
|
if (num_tasksOperand.has_value())
|
|
num_tasksOperands.push_back(*num_tasksOperand);
|
|
if (num_tasksType)
|
|
num_tasksTypes.push_back(num_tasksType);
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("priority"))) {
|
|
|
|
if (priorityClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`priority` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
priorityClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
priorityOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
priorityOperands.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();
|
|
priorityTypes.push_back(optionalType);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("untied"))) {
|
|
|
|
if (untiedClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`untied` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
untiedClause = true;
|
|
result.getOrAddProperties<TaskloopContextOp::Properties>().untied = parser.getBuilder().getUnitAttr(); } else {
|
|
break;
|
|
}
|
|
}
|
|
{
|
|
in_reduction_varsOperandsLoc = parser.getCurrentLocation();
|
|
private_varsOperandsLoc = parser.getCurrentLocation();
|
|
reduction_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseInReductionPrivateReductionRegion(parser, *regionRegion, in_reduction_varsOperands, in_reduction_varsTypes, in_reduction_byrefAttr, in_reduction_symsAttr, private_varsOperands, private_varsTypes, private_symsAttr, private_needs_barrierAttr, reduction_modAttr, reduction_varsOperands, reduction_varsTypes, reduction_byrefAttr, reduction_symsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (in_reduction_byrefAttr)
|
|
result.getOrAddProperties<TaskloopContextOp::Properties>().in_reduction_byref = in_reduction_byrefAttr;
|
|
if (in_reduction_symsAttr)
|
|
result.getOrAddProperties<TaskloopContextOp::Properties>().in_reduction_syms = in_reduction_symsAttr;
|
|
if (private_symsAttr)
|
|
result.getOrAddProperties<TaskloopContextOp::Properties>().private_syms = private_symsAttr;
|
|
if (private_needs_barrierAttr)
|
|
result.getOrAddProperties<TaskloopContextOp::Properties>().private_needs_barrier = private_needs_barrierAttr;
|
|
if (reduction_modAttr)
|
|
result.getOrAddProperties<TaskloopContextOp::Properties>().reduction_mod = reduction_modAttr;
|
|
if (reduction_byrefAttr)
|
|
result.getOrAddProperties<TaskloopContextOp::Properties>().reduction_byref = reduction_byrefAttr;
|
|
if (reduction_symsAttr)
|
|
result.getOrAddProperties<TaskloopContextOp::Properties>().reduction_syms = reduction_symsAttr;
|
|
}
|
|
{
|
|
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<int32_t>({static_cast<int32_t>(allocate_varsOperands.size()), static_cast<int32_t>(allocator_varsOperands.size()), static_cast<int32_t>(finalOperands.size()), static_cast<int32_t>(grainsizeOperands.size()), static_cast<int32_t>(if_exprOperands.size()), static_cast<int32_t>(in_reduction_varsOperands.size()), static_cast<int32_t>(num_tasksOperands.size()), static_cast<int32_t>(priorityOperands.size()), static_cast<int32_t>(private_varsOperands.size()), static_cast<int32_t>(reduction_varsOperands.size())}), result.getOrAddProperties<TaskloopContextOp::Properties>().operandSegmentSizes.begin());
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1);
|
|
if (parser.resolveOperands(allocate_varsOperands, allocate_varsTypes, allocate_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(allocator_varsOperands, allocator_varsTypes, allocator_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!finalOperands.empty()) {
|
|
if (parser.resolveOperands(finalOperands, odsBuildableType0, finalOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (!grainsizeOperands.empty()) {
|
|
if (parser.resolveOperands(grainsizeOperands, grainsizeTypes, grainsizeOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (!if_exprOperands.empty()) {
|
|
if (parser.resolveOperands(if_exprOperands, odsBuildableType0, if_exprOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(in_reduction_varsOperands, in_reduction_varsTypes, in_reduction_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!num_tasksOperands.empty()) {
|
|
if (parser.resolveOperands(num_tasksOperands, num_tasksTypes, num_tasksOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (!priorityOperands.empty()) {
|
|
if (parser.resolveOperands(priorityOperands, priorityTypes, priorityOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(private_varsOperands, private_varsTypes, private_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(reduction_varsOperands, reduction_varsTypes, reduction_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TaskloopContextOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getAllocateVars().size() || getAllocatorVars().size()) {
|
|
_odsPrinter << ' ' << "allocate";
|
|
_odsPrinter << "(";
|
|
printAllocateAndAllocator(_odsPrinter, *this, getAllocateVars(), getAllocateVars().getTypes(), getAllocatorVars(), getAllocatorVars().getTypes());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getFinal()) {
|
|
_odsPrinter << ' ' << "final";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getFinal())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getGrainsizeModAttr()) || getGrainsize()) {
|
|
_odsPrinter << ' ' << "grainsize";
|
|
_odsPrinter << "(";
|
|
printGrainsizeClause(_odsPrinter, *this, getGrainsizeModAttr(), getGrainsize(), (getGrainsize() ? getGrainsize().getType() : ::mlir::Type()));
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getIfExpr()) {
|
|
_odsPrinter << ' ' << "if";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getIfExpr())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getMergeableAttr() && getMergeableAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "mergeable";
|
|
}
|
|
if (false || ((getNogroupAttr() && getNogroupAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "nogroup";
|
|
}
|
|
if (false || (getNumTasksModAttr()) || getNumTasks()) {
|
|
_odsPrinter << ' ' << "num_tasks";
|
|
_odsPrinter << "(";
|
|
printNumTasksClause(_odsPrinter, *this, getNumTasksModAttr(), getNumTasks(), (getNumTasks() ? getNumTasks().getType() : ::mlir::Type()));
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getPriority()) {
|
|
_odsPrinter << ' ' << "priority";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getPriority())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << (getPriority() ? ::llvm::ArrayRef<::mlir::Type>(getPriority().getType()) : ::llvm::ArrayRef<::mlir::Type>());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getUntiedAttr() && getUntiedAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "untied";
|
|
}
|
|
_odsPrinter << ' ';
|
|
printInReductionPrivateReductionRegion(_odsPrinter, *this, getRegion(), getInReductionVars(), getInReductionVars().getTypes(), getInReductionByrefAttr(), getInReductionSymsAttr(), getPrivateVars(), getPrivateVars().getTypes(), getPrivateSymsAttr(), getPrivateNeedsBarrierAttr(), getReductionModAttr(), getReductionVars(), getReductionVars().getTypes(), getReductionByrefAttr(), getReductionSymsAttr());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("grainsize_mod");
|
|
elidedAttrs.push_back("mergeable");
|
|
elidedAttrs.push_back("nogroup");
|
|
elidedAttrs.push_back("num_tasks_mod");
|
|
elidedAttrs.push_back("untied");
|
|
elidedAttrs.push_back("in_reduction_byref");
|
|
elidedAttrs.push_back("in_reduction_syms");
|
|
elidedAttrs.push_back("private_syms");
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
elidedAttrs.push_back("reduction_mod");
|
|
elidedAttrs.push_back("reduction_byref");
|
|
elidedAttrs.push_back("reduction_syms");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getMergeableAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("mergeable");
|
|
}
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getNogroupAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("nogroup");
|
|
}
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getPrivateNeedsBarrierAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
}
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getUntiedAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("untied");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::TaskloopContextOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::TaskloopContextOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::TaskloopWrapperOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TaskloopWrapperOpGenericAdaptorBase::TaskloopWrapperOpGenericAdaptorBase(TaskloopWrapperOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
TaskloopWrapperOpAdaptor::TaskloopWrapperOpAdaptor(TaskloopWrapperOp op) : TaskloopWrapperOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TaskloopWrapperOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TaskloopWrapperOp::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 TaskloopWrapperOp::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 TaskloopWrapperOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TaskloopWrapperOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TaskloopWrapperOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void TaskloopWrapperOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult TaskloopWrapperOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
TaskloopWrapperOp TaskloopWrapperOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const TaskloopWrapperOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<TaskloopWrapperOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskloopWrapperOp TaskloopWrapperOp::create(::mlir::ImplicitLocOpBuilder &builder, const TaskloopWrapperOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void TaskloopWrapperOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) {
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
TaskloopWrapperOp TaskloopWrapperOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__);
|
|
auto __res__ = ::llvm::dyn_cast<TaskloopWrapperOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskloopWrapperOp TaskloopWrapperOp::create(::mlir::ImplicitLocOpBuilder &builder) {
|
|
return create(builder, builder.getLoc());
|
|
}
|
|
|
|
void TaskloopWrapperOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) {
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TaskloopWrapperOp TaskloopWrapperOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes));
|
|
auto __res__ = ::llvm::dyn_cast<TaskloopWrapperOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskloopWrapperOp TaskloopWrapperOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes));
|
|
}
|
|
|
|
void TaskloopWrapperOp::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);
|
|
}
|
|
|
|
TaskloopWrapperOp TaskloopWrapperOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<TaskloopWrapperOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskloopWrapperOp TaskloopWrapperOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void TaskloopWrapperOp::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&>(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);
|
|
}
|
|
|
|
TaskloopWrapperOp TaskloopWrapperOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<TaskloopWrapperOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskloopWrapperOp TaskloopWrapperOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult TaskloopWrapperOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TaskloopWrapperOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult TaskloopWrapperOp::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();
|
|
|
|
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));
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TaskloopWrapperOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getRegion());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::TaskloopWrapperOp)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::TaskwaitOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TaskwaitOpGenericAdaptorBase::TaskwaitOpGenericAdaptorBase(TaskwaitOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> TaskwaitOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskwaitOpGenericAdaptorBase::getDependKinds() {
|
|
auto attr = getDependKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskwaitOpGenericAdaptorBase::getDependIteratedKinds() {
|
|
auto attr = getDependIteratedKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr TaskwaitOpGenericAdaptorBase::getNowaitAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nowait);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool TaskwaitOpGenericAdaptorBase::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
TaskwaitOpAdaptor::TaskwaitOpAdaptor(TaskwaitOp op) : TaskwaitOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TaskwaitOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_depend_iterated_kinds = getProperties().depend_iterated_kinds; (void)tblgen_depend_iterated_kinds;
|
|
auto tblgen_depend_kinds = getProperties().depend_kinds; (void)tblgen_depend_kinds;
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
|
|
if (tblgen_depend_kinds && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_depend_kinds))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_depend_kinds), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::omp::ClauseTaskDependAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.taskwait' op attribute 'depend_kinds' failed to satisfy constraint: depend clause in a target or task construct array");
|
|
|
|
if (tblgen_depend_iterated_kinds && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_depend_iterated_kinds))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_depend_iterated_kinds), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::omp::ClauseTaskDependAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.taskwait' op attribute 'depend_iterated_kinds' failed to satisfy constraint: depend clause in a target or task construct array");
|
|
|
|
if (tblgen_nowait && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nowait))))
|
|
return emitError(loc, "'omp.taskwait' op attribute 'nowait' failed to satisfy constraint: unit attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> TaskwaitOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange TaskwaitOp::getDependVarsMutable() {
|
|
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 TaskwaitOp::getDependIteratedMutable() {
|
|
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 TaskwaitOp::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.depend_iterated_kinds;
|
|
auto attr = dict.get("depend_iterated_kinds");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `depend_iterated_kinds` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.depend_kinds;
|
|
auto attr = dict.get("depend_kinds");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `depend_kinds` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.nowait;
|
|
auto attr = dict.get("nowait");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nowait` 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 TaskwaitOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.depend_iterated_kinds;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("depend_iterated_kinds",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.depend_kinds;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("depend_kinds",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.nowait;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nowait",
|
|
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 TaskwaitOp::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.depend_iterated_kinds.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.depend_kinds.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.nowait.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TaskwaitOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "depend_iterated_kinds")
|
|
return prop.depend_iterated_kinds;
|
|
|
|
if (name == "depend_kinds")
|
|
return prop.depend_kinds;
|
|
|
|
if (name == "nowait")
|
|
return prop.nowait;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TaskwaitOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "depend_iterated_kinds") {
|
|
prop.depend_iterated_kinds = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.depend_iterated_kinds)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "depend_kinds") {
|
|
prop.depend_kinds = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.depend_kinds)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "nowait") {
|
|
prop.nowait = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nowait)>>(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 TaskwaitOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.depend_iterated_kinds) attrs.append("depend_iterated_kinds", prop.depend_iterated_kinds);
|
|
|
|
if (prop.depend_kinds) attrs.append("depend_kinds", prop.depend_kinds);
|
|
|
|
if (prop.nowait) attrs.append("nowait", prop.nowait);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult TaskwaitOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDependIteratedKindsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(attr, "depend_iterated_kinds", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDependKindsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(attr, "depend_kinds", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNowaitAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "nowait", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TaskwaitOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.depend_iterated_kinds)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.depend_kinds)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nowait)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(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 TaskwaitOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.depend_iterated_kinds);
|
|
|
|
writer.writeOptionalAttribute(prop.depend_kinds);
|
|
|
|
writer.writeOptionalAttribute(prop.nowait);
|
|
|
|
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 > TaskwaitOp::getDependKinds() {
|
|
auto attr = getDependKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TaskwaitOp::getDependIteratedKinds() {
|
|
auto attr = getDependIteratedKindsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool TaskwaitOp::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
void TaskwaitOp::setNowait(bool attrValue) {
|
|
auto &odsProp = getProperties().nowait;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
TaskwaitOp TaskwaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const TaskwaitOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<TaskwaitOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskwaitOp TaskwaitOp::create(::mlir::ImplicitLocOpBuilder &builder, const TaskwaitOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void TaskwaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
}
|
|
|
|
TaskwaitOp TaskwaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<TaskwaitOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskwaitOp TaskwaitOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void TaskwaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TaskwaitOp TaskwaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<TaskwaitOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskwaitOp TaskwaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/::mlir::UnitAttr nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void TaskwaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/bool nowait) {
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
}
|
|
|
|
TaskwaitOp TaskwaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/bool nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<TaskwaitOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskwaitOp TaskwaitOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/bool nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void TaskwaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/bool nowait) {
|
|
odsState.addOperands(depend_vars);
|
|
odsState.addOperands(depend_iterated);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(depend_vars.size()), static_cast<int32_t>(depend_iterated.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (depend_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_kinds = depend_kinds;
|
|
}
|
|
if (depend_iterated_kinds) {
|
|
odsState.getOrAddProperties<Properties>().depend_iterated_kinds = depend_iterated_kinds;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TaskwaitOp TaskwaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/bool nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<TaskwaitOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskwaitOp TaskwaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr depend_kinds, ::mlir::ValueRange depend_vars, /*optional*/::mlir::ArrayAttr depend_iterated_kinds, ::mlir::ValueRange depend_iterated, /*optional*/bool nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(depend_kinds)>(depend_kinds), std::forward<decltype(depend_vars)>(depend_vars), std::forward<decltype(depend_iterated_kinds)>(depend_iterated_kinds), std::forward<decltype(depend_iterated)>(depend_iterated), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void TaskwaitOp::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<TaskwaitOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
TaskwaitOp TaskwaitOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<TaskwaitOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskwaitOp TaskwaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void TaskwaitOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TaskwaitOp TaskwaitOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<TaskwaitOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskwaitOp TaskwaitOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult TaskwaitOp::verifyInvariantsImpl() {
|
|
auto tblgen_depend_iterated_kinds = getProperties().depend_iterated_kinds; (void)tblgen_depend_iterated_kinds;
|
|
auto tblgen_depend_kinds = getProperties().depend_kinds; (void)tblgen_depend_kinds;
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(*this, tblgen_depend_kinds, "depend_kinds")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps30(*this, tblgen_depend_iterated_kinds, "depend_iterated_kinds")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_nowait, "nowait")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps11(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TaskwaitOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult TaskwaitOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> depend_varsOperands;
|
|
::llvm::SMLoc depend_varsOperandsLoc;
|
|
(void)depend_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> depend_varsTypes;
|
|
::mlir::ArrayAttr depend_kindsAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> depend_iteratedOperands;
|
|
::llvm::SMLoc depend_iteratedOperandsLoc;
|
|
(void)depend_iteratedOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> depend_iteratedTypes;
|
|
::mlir::ArrayAttr depend_iterated_kindsAttr;
|
|
bool dependClause = false;
|
|
bool nowaitClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("depend"))) {
|
|
|
|
if (dependClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`depend` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
dependClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
depend_varsOperandsLoc = parser.getCurrentLocation();
|
|
depend_iteratedOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseDependVarList(parser, depend_varsOperands, depend_varsTypes, depend_kindsAttr, depend_iteratedOperands, depend_iteratedTypes, depend_iterated_kindsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (depend_kindsAttr)
|
|
result.getOrAddProperties<TaskwaitOp::Properties>().depend_kinds = depend_kindsAttr;
|
|
if (depend_iterated_kindsAttr)
|
|
result.getOrAddProperties<TaskwaitOp::Properties>().depend_iterated_kinds = depend_iterated_kindsAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("nowait"))) {
|
|
|
|
if (nowaitClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`nowait` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
nowaitClause = true;
|
|
result.getOrAddProperties<TaskwaitOp::Properties>().nowait = parser.getBuilder().getUnitAttr(); } 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<int32_t>({static_cast<int32_t>(depend_varsOperands.size()), static_cast<int32_t>(depend_iteratedOperands.size())}), result.getOrAddProperties<TaskwaitOp::Properties>().operandSegmentSizes.begin());
|
|
if (parser.resolveOperands(depend_varsOperands, depend_varsTypes, depend_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(depend_iteratedOperands, depend_iteratedTypes, depend_iteratedOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TaskwaitOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getDependVars().size() || (getDependKindsAttr()) || getDependIterated().size() || (getDependIteratedKindsAttr())) {
|
|
_odsPrinter << ' ' << "depend";
|
|
_odsPrinter << "(";
|
|
printDependVarList(_odsPrinter, *this, getDependVars(), getDependVars().getTypes(), getDependKindsAttr(), getDependIterated(), getDependIterated().getTypes(), getDependIteratedKindsAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getNowaitAttr() && getNowaitAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "nowait";
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("depend_kinds");
|
|
elidedAttrs.push_back("depend_iterated_kinds");
|
|
elidedAttrs.push_back("nowait");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getNowaitAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("nowait");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::TaskwaitOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::TaskwaitOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::TaskyieldOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TaskyieldOpGenericAdaptorBase::TaskyieldOpGenericAdaptorBase(TaskyieldOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
TaskyieldOpAdaptor::TaskyieldOpAdaptor(TaskyieldOp op) : TaskyieldOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TaskyieldOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TaskyieldOp::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 TaskyieldOp::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 TaskyieldOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TaskyieldOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TaskyieldOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void TaskyieldOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult TaskyieldOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TaskyieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) {
|
|
}
|
|
|
|
TaskyieldOp TaskyieldOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__);
|
|
auto __res__ = ::llvm::dyn_cast<TaskyieldOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskyieldOp TaskyieldOp::create(::mlir::ImplicitLocOpBuilder &builder) {
|
|
return create(builder, builder.getLoc());
|
|
}
|
|
|
|
void TaskyieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) {
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TaskyieldOp TaskyieldOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes));
|
|
auto __res__ = ::llvm::dyn_cast<TaskyieldOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskyieldOp TaskyieldOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes));
|
|
}
|
|
|
|
void TaskyieldOp::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);
|
|
}
|
|
|
|
TaskyieldOp TaskyieldOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<TaskyieldOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskyieldOp TaskyieldOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void TaskyieldOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TaskyieldOp TaskyieldOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<TaskyieldOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TaskyieldOp TaskyieldOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult TaskyieldOp::verifyInvariantsImpl() {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TaskyieldOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult TaskyieldOp::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 TaskyieldOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::TaskyieldOp)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::TeamsOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TeamsOpGenericAdaptorBase::TeamsOpGenericAdaptorBase(TeamsOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> TeamsOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::std::optional<::mlir::omp::AccessGroupModifier> TeamsOpGenericAdaptorBase::getDynGroupprivateAccessGroup() {
|
|
auto attr = getDynGroupprivateAccessGroupAttr();
|
|
return attr ? ::std::optional<::mlir::omp::AccessGroupModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::FallbackModifier> TeamsOpGenericAdaptorBase::getDynGroupprivateFallback() {
|
|
auto attr = getDynGroupprivateFallbackAttr();
|
|
return attr ? ::std::optional<::mlir::omp::FallbackModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TeamsOpGenericAdaptorBase::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr TeamsOpGenericAdaptorBase::getPrivateNeedsBarrierAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().private_needs_barrier);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool TeamsOpGenericAdaptorBase::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ReductionModifier> TeamsOpGenericAdaptorBase::getReductionMod() {
|
|
auto attr = getReductionModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ReductionModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> TeamsOpGenericAdaptorBase::getReductionByref() {
|
|
auto attr = getReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TeamsOpGenericAdaptorBase::getReductionSyms() {
|
|
auto attr = getReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
TeamsOpAdaptor::TeamsOpAdaptor(TeamsOp op) : TeamsOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TeamsOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_dyn_groupprivate_access_group = getProperties().dyn_groupprivate_access_group; (void)tblgen_dyn_groupprivate_access_group;
|
|
auto tblgen_dyn_groupprivate_fallback = getProperties().dyn_groupprivate_fallback; (void)tblgen_dyn_groupprivate_fallback;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_reduction_byref = getProperties().reduction_byref; (void)tblgen_reduction_byref;
|
|
auto tblgen_reduction_mod = getProperties().reduction_mod; (void)tblgen_reduction_mod;
|
|
auto tblgen_reduction_syms = getProperties().reduction_syms; (void)tblgen_reduction_syms;
|
|
|
|
if (tblgen_dyn_groupprivate_access_group && !((::llvm::isa<::mlir::omp::AccessGroupModifierAttr>(tblgen_dyn_groupprivate_access_group))))
|
|
return emitError(loc, "'omp.teams' op attribute 'dyn_groupprivate_access_group' failed to satisfy constraint: access group modifier");
|
|
|
|
if (tblgen_dyn_groupprivate_fallback && !((::llvm::isa<::mlir::omp::FallbackModifierAttr>(tblgen_dyn_groupprivate_fallback))))
|
|
return emitError(loc, "'omp.teams' op attribute 'dyn_groupprivate_fallback' failed to satisfy constraint: fallback modifier");
|
|
|
|
if (tblgen_private_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_private_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_private_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.teams' op attribute 'private_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_private_needs_barrier && !((::llvm::isa<::mlir::UnitAttr>(tblgen_private_needs_barrier))))
|
|
return emitError(loc, "'omp.teams' op attribute 'private_needs_barrier' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_reduction_mod && !((::llvm::isa<::mlir::omp::ReductionModifierAttr>(tblgen_reduction_mod))))
|
|
return emitError(loc, "'omp.teams' op attribute 'reduction_mod' failed to satisfy constraint: reduction modifier");
|
|
|
|
if (tblgen_reduction_byref && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(tblgen_reduction_byref))))
|
|
return emitError(loc, "'omp.teams' op attribute 'reduction_byref' failed to satisfy constraint: i1 dense array attribute");
|
|
|
|
if (tblgen_reduction_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_reduction_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_reduction_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.teams' op attribute 'reduction_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> TeamsOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange TeamsOp::getAllocateVarsMutable() {
|
|
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 TeamsOp::getAllocatorVarsMutable() {
|
|
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 TeamsOp::getDynGroupprivateSizeMutable() {
|
|
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 TeamsOp::getIfExprMutable() {
|
|
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 TeamsOp::getNumTeamsLowerMutable() {
|
|
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 TeamsOp::getNumTeamsUpperVarsMutable() {
|
|
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 TeamsOp::getPrivateVarsMutable() {
|
|
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 TeamsOp::getReductionVarsMutable() {
|
|
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 TeamsOp::getThreadLimitVarsMutable() {
|
|
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;
|
|
}
|
|
|
|
::llvm::LogicalResult TeamsOp::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.dyn_groupprivate_access_group;
|
|
auto attr = dict.get("dyn_groupprivate_access_group");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `dyn_groupprivate_access_group` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.dyn_groupprivate_fallback;
|
|
auto attr = dict.get("dyn_groupprivate_fallback");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `dyn_groupprivate_fallback` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_needs_barrier;
|
|
auto attr = dict.get("private_needs_barrier");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_needs_barrier` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_syms;
|
|
auto attr = dict.get("private_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_syms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_byref;
|
|
auto attr = dict.get("reduction_byref");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_byref` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_mod;
|
|
auto attr = dict.get("reduction_mod");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_mod` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_syms;
|
|
auto attr = dict.get("reduction_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_syms` 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 TeamsOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.dyn_groupprivate_access_group;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("dyn_groupprivate_access_group",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.dyn_groupprivate_fallback;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("dyn_groupprivate_fallback",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_needs_barrier;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_needs_barrier",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_syms",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_byref;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_byref",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_mod;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_mod",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_syms",
|
|
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 TeamsOp::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.dyn_groupprivate_access_group.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.dyn_groupprivate_fallback.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_needs_barrier.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_syms.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_byref.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_mod.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_syms.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TeamsOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "dyn_groupprivate_access_group")
|
|
return prop.dyn_groupprivate_access_group;
|
|
|
|
if (name == "dyn_groupprivate_fallback")
|
|
return prop.dyn_groupprivate_fallback;
|
|
|
|
if (name == "private_needs_barrier")
|
|
return prop.private_needs_barrier;
|
|
|
|
if (name == "private_syms")
|
|
return prop.private_syms;
|
|
|
|
if (name == "reduction_byref")
|
|
return prop.reduction_byref;
|
|
|
|
if (name == "reduction_mod")
|
|
return prop.reduction_mod;
|
|
|
|
if (name == "reduction_syms")
|
|
return prop.reduction_syms;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TeamsOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "dyn_groupprivate_access_group") {
|
|
prop.dyn_groupprivate_access_group = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.dyn_groupprivate_access_group)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "dyn_groupprivate_fallback") {
|
|
prop.dyn_groupprivate_fallback = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.dyn_groupprivate_fallback)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_needs_barrier") {
|
|
prop.private_needs_barrier = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_needs_barrier)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_syms") {
|
|
prop.private_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_syms)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_byref") {
|
|
prop.reduction_byref = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_byref)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_mod") {
|
|
prop.reduction_mod = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_mod)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_syms") {
|
|
prop.reduction_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_syms)>>(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 TeamsOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.dyn_groupprivate_access_group) attrs.append("dyn_groupprivate_access_group", prop.dyn_groupprivate_access_group);
|
|
|
|
if (prop.dyn_groupprivate_fallback) attrs.append("dyn_groupprivate_fallback", prop.dyn_groupprivate_fallback);
|
|
|
|
if (prop.private_needs_barrier) attrs.append("private_needs_barrier", prop.private_needs_barrier);
|
|
|
|
if (prop.private_syms) attrs.append("private_syms", prop.private_syms);
|
|
|
|
if (prop.reduction_byref) attrs.append("reduction_byref", prop.reduction_byref);
|
|
|
|
if (prop.reduction_mod) attrs.append("reduction_mod", prop.reduction_mod);
|
|
|
|
if (prop.reduction_syms) attrs.append("reduction_syms", prop.reduction_syms);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult TeamsOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDynGroupprivateAccessGroupAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps31(attr, "dyn_groupprivate_access_group", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDynGroupprivateFallbackAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps32(attr, "dyn_groupprivate_fallback", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateNeedsBarrierAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "private_needs_barrier", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "private_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionByrefAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(attr, "reduction_byref", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionModAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps19(attr, "reduction_mod", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "reduction_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TeamsOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.dyn_groupprivate_access_group)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.dyn_groupprivate_fallback)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_needs_barrier)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_syms)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_byref)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_mod)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_syms)))
|
|
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 TeamsOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.dyn_groupprivate_access_group);
|
|
|
|
writer.writeOptionalAttribute(prop.dyn_groupprivate_fallback);
|
|
|
|
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
|
|
}
|
|
|
|
writer.writeOptionalAttribute(prop.private_needs_barrier);
|
|
|
|
writer.writeOptionalAttribute(prop.private_syms);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_byref);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_mod);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_syms);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
::std::optional<::mlir::omp::AccessGroupModifier> TeamsOp::getDynGroupprivateAccessGroup() {
|
|
auto attr = getDynGroupprivateAccessGroupAttr();
|
|
return attr ? ::std::optional<::mlir::omp::AccessGroupModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::FallbackModifier> TeamsOp::getDynGroupprivateFallback() {
|
|
auto attr = getDynGroupprivateFallbackAttr();
|
|
return attr ? ::std::optional<::mlir::omp::FallbackModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TeamsOp::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool TeamsOp::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ReductionModifier> TeamsOp::getReductionMod() {
|
|
auto attr = getReductionModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ReductionModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> TeamsOp::getReductionByref() {
|
|
auto attr = getReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > TeamsOp::getReductionSyms() {
|
|
auto attr = getReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
void TeamsOp::setDynGroupprivateAccessGroup(::std::optional<::mlir::omp::AccessGroupModifier> attrValue) {
|
|
auto &odsProp = getProperties().dyn_groupprivate_access_group;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::AccessGroupModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TeamsOp::setDynGroupprivateFallback(::std::optional<::mlir::omp::FallbackModifier> attrValue) {
|
|
auto &odsProp = getProperties().dyn_groupprivate_fallback;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::FallbackModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TeamsOp::setPrivateNeedsBarrier(bool attrValue) {
|
|
auto &odsProp = getProperties().private_needs_barrier;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TeamsOp::setReductionMod(::std::optional<::mlir::omp::ReductionModifier> attrValue) {
|
|
auto &odsProp = getProperties().reduction_mod;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ReductionModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TeamsOp::setReductionByref(::std::optional<::llvm::ArrayRef<bool>> attrValue) {
|
|
auto &odsProp = getProperties().reduction_byref;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getDenseBoolArrayAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
TeamsOp TeamsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const TeamsOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<TeamsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TeamsOp TeamsOp::create(::mlir::ImplicitLocOpBuilder &builder, const TeamsOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void TeamsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, /*optional*/::mlir::Value if_expr, /*optional*/::mlir::Value num_teams_lower, ::mlir::ValueRange num_teams_upper_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, ::mlir::ValueRange thread_limit_vars) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
if (dyn_groupprivate_size)
|
|
odsState.addOperands(dyn_groupprivate_size);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
if (num_teams_lower)
|
|
odsState.addOperands(num_teams_lower);
|
|
odsState.addOperands(num_teams_upper_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
odsState.addOperands(thread_limit_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), (dyn_groupprivate_size ? 1 : 0), (if_expr ? 1 : 0), (num_teams_lower ? 1 : 0), static_cast<int32_t>(num_teams_upper_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size()), static_cast<int32_t>(thread_limit_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (dyn_groupprivate_access_group) {
|
|
odsState.getOrAddProperties<Properties>().dyn_groupprivate_access_group = dyn_groupprivate_access_group;
|
|
}
|
|
if (dyn_groupprivate_fallback) {
|
|
odsState.getOrAddProperties<Properties>().dyn_groupprivate_fallback = dyn_groupprivate_fallback;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
TeamsOp TeamsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, /*optional*/::mlir::Value if_expr, /*optional*/::mlir::Value num_teams_lower, ::mlir::ValueRange num_teams_upper_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, ::mlir::ValueRange thread_limit_vars) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(dyn_groupprivate_access_group)>(dyn_groupprivate_access_group), std::forward<decltype(dyn_groupprivate_fallback)>(dyn_groupprivate_fallback), std::forward<decltype(dyn_groupprivate_size)>(dyn_groupprivate_size), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(num_teams_lower)>(num_teams_lower), std::forward<decltype(num_teams_upper_vars)>(num_teams_upper_vars), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(thread_limit_vars)>(thread_limit_vars));
|
|
auto __res__ = ::llvm::dyn_cast<TeamsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TeamsOp TeamsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, /*optional*/::mlir::Value if_expr, /*optional*/::mlir::Value num_teams_lower, ::mlir::ValueRange num_teams_upper_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, ::mlir::ValueRange thread_limit_vars) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(dyn_groupprivate_access_group)>(dyn_groupprivate_access_group), std::forward<decltype(dyn_groupprivate_fallback)>(dyn_groupprivate_fallback), std::forward<decltype(dyn_groupprivate_size)>(dyn_groupprivate_size), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(num_teams_lower)>(num_teams_lower), std::forward<decltype(num_teams_upper_vars)>(num_teams_upper_vars), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(thread_limit_vars)>(thread_limit_vars));
|
|
}
|
|
|
|
void TeamsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, /*optional*/::mlir::Value if_expr, /*optional*/::mlir::Value num_teams_lower, ::mlir::ValueRange num_teams_upper_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, ::mlir::ValueRange thread_limit_vars) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
if (dyn_groupprivate_size)
|
|
odsState.addOperands(dyn_groupprivate_size);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
if (num_teams_lower)
|
|
odsState.addOperands(num_teams_lower);
|
|
odsState.addOperands(num_teams_upper_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
odsState.addOperands(thread_limit_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), (dyn_groupprivate_size ? 1 : 0), (if_expr ? 1 : 0), (num_teams_lower ? 1 : 0), static_cast<int32_t>(num_teams_upper_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size()), static_cast<int32_t>(thread_limit_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (dyn_groupprivate_access_group) {
|
|
odsState.getOrAddProperties<Properties>().dyn_groupprivate_access_group = dyn_groupprivate_access_group;
|
|
}
|
|
if (dyn_groupprivate_fallback) {
|
|
odsState.getOrAddProperties<Properties>().dyn_groupprivate_fallback = dyn_groupprivate_fallback;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TeamsOp TeamsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, /*optional*/::mlir::Value if_expr, /*optional*/::mlir::Value num_teams_lower, ::mlir::ValueRange num_teams_upper_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, ::mlir::ValueRange thread_limit_vars) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(dyn_groupprivate_access_group)>(dyn_groupprivate_access_group), std::forward<decltype(dyn_groupprivate_fallback)>(dyn_groupprivate_fallback), std::forward<decltype(dyn_groupprivate_size)>(dyn_groupprivate_size), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(num_teams_lower)>(num_teams_lower), std::forward<decltype(num_teams_upper_vars)>(num_teams_upper_vars), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(thread_limit_vars)>(thread_limit_vars));
|
|
auto __res__ = ::llvm::dyn_cast<TeamsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TeamsOp TeamsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, /*optional*/::mlir::Value if_expr, /*optional*/::mlir::Value num_teams_lower, ::mlir::ValueRange num_teams_upper_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, ::mlir::ValueRange thread_limit_vars) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(dyn_groupprivate_access_group)>(dyn_groupprivate_access_group), std::forward<decltype(dyn_groupprivate_fallback)>(dyn_groupprivate_fallback), std::forward<decltype(dyn_groupprivate_size)>(dyn_groupprivate_size), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(num_teams_lower)>(num_teams_lower), std::forward<decltype(num_teams_upper_vars)>(num_teams_upper_vars), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(thread_limit_vars)>(thread_limit_vars));
|
|
}
|
|
|
|
void TeamsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, /*optional*/::mlir::Value if_expr, /*optional*/::mlir::Value num_teams_lower, ::mlir::ValueRange num_teams_upper_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, ::mlir::ValueRange thread_limit_vars) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
if (dyn_groupprivate_size)
|
|
odsState.addOperands(dyn_groupprivate_size);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
if (num_teams_lower)
|
|
odsState.addOperands(num_teams_lower);
|
|
odsState.addOperands(num_teams_upper_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
odsState.addOperands(thread_limit_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), (dyn_groupprivate_size ? 1 : 0), (if_expr ? 1 : 0), (num_teams_lower ? 1 : 0), static_cast<int32_t>(num_teams_upper_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size()), static_cast<int32_t>(thread_limit_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (dyn_groupprivate_access_group) {
|
|
odsState.getOrAddProperties<Properties>().dyn_groupprivate_access_group = dyn_groupprivate_access_group;
|
|
}
|
|
if (dyn_groupprivate_fallback) {
|
|
odsState.getOrAddProperties<Properties>().dyn_groupprivate_fallback = dyn_groupprivate_fallback;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
TeamsOp TeamsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, /*optional*/::mlir::Value if_expr, /*optional*/::mlir::Value num_teams_lower, ::mlir::ValueRange num_teams_upper_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, ::mlir::ValueRange thread_limit_vars) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(dyn_groupprivate_access_group)>(dyn_groupprivate_access_group), std::forward<decltype(dyn_groupprivate_fallback)>(dyn_groupprivate_fallback), std::forward<decltype(dyn_groupprivate_size)>(dyn_groupprivate_size), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(num_teams_lower)>(num_teams_lower), std::forward<decltype(num_teams_upper_vars)>(num_teams_upper_vars), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(thread_limit_vars)>(thread_limit_vars));
|
|
auto __res__ = ::llvm::dyn_cast<TeamsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TeamsOp TeamsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, /*optional*/::mlir::Value if_expr, /*optional*/::mlir::Value num_teams_lower, ::mlir::ValueRange num_teams_upper_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, ::mlir::ValueRange thread_limit_vars) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(dyn_groupprivate_access_group)>(dyn_groupprivate_access_group), std::forward<decltype(dyn_groupprivate_fallback)>(dyn_groupprivate_fallback), std::forward<decltype(dyn_groupprivate_size)>(dyn_groupprivate_size), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(num_teams_lower)>(num_teams_lower), std::forward<decltype(num_teams_upper_vars)>(num_teams_upper_vars), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(thread_limit_vars)>(thread_limit_vars));
|
|
}
|
|
|
|
void TeamsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, /*optional*/::mlir::Value if_expr, /*optional*/::mlir::Value num_teams_lower, ::mlir::ValueRange num_teams_upper_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, ::mlir::ValueRange thread_limit_vars) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
if (dyn_groupprivate_size)
|
|
odsState.addOperands(dyn_groupprivate_size);
|
|
if (if_expr)
|
|
odsState.addOperands(if_expr);
|
|
if (num_teams_lower)
|
|
odsState.addOperands(num_teams_lower);
|
|
odsState.addOperands(num_teams_upper_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
odsState.addOperands(thread_limit_vars);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), (dyn_groupprivate_size ? 1 : 0), (if_expr ? 1 : 0), (num_teams_lower ? 1 : 0), static_cast<int32_t>(num_teams_upper_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size()), static_cast<int32_t>(thread_limit_vars.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (dyn_groupprivate_access_group) {
|
|
odsState.getOrAddProperties<Properties>().dyn_groupprivate_access_group = dyn_groupprivate_access_group;
|
|
}
|
|
if (dyn_groupprivate_fallback) {
|
|
odsState.getOrAddProperties<Properties>().dyn_groupprivate_fallback = dyn_groupprivate_fallback;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TeamsOp TeamsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, /*optional*/::mlir::Value if_expr, /*optional*/::mlir::Value num_teams_lower, ::mlir::ValueRange num_teams_upper_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, ::mlir::ValueRange thread_limit_vars) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(dyn_groupprivate_access_group)>(dyn_groupprivate_access_group), std::forward<decltype(dyn_groupprivate_fallback)>(dyn_groupprivate_fallback), std::forward<decltype(dyn_groupprivate_size)>(dyn_groupprivate_size), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(num_teams_lower)>(num_teams_lower), std::forward<decltype(num_teams_upper_vars)>(num_teams_upper_vars), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(thread_limit_vars)>(thread_limit_vars));
|
|
auto __res__ = ::llvm::dyn_cast<TeamsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TeamsOp TeamsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, /*optional*/::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_group, /*optional*/::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallback, /*optional*/::mlir::Value dyn_groupprivate_size, /*optional*/::mlir::Value if_expr, /*optional*/::mlir::Value num_teams_lower, ::mlir::ValueRange num_teams_upper_vars, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, ::mlir::ValueRange thread_limit_vars) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(dyn_groupprivate_access_group)>(dyn_groupprivate_access_group), std::forward<decltype(dyn_groupprivate_fallback)>(dyn_groupprivate_fallback), std::forward<decltype(dyn_groupprivate_size)>(dyn_groupprivate_size), std::forward<decltype(if_expr)>(if_expr), std::forward<decltype(num_teams_lower)>(num_teams_lower), std::forward<decltype(num_teams_upper_vars)>(num_teams_upper_vars), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(thread_limit_vars)>(thread_limit_vars));
|
|
}
|
|
|
|
void TeamsOp::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<TeamsOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
TeamsOp TeamsOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<TeamsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TeamsOp TeamsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void TeamsOp::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&>(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);
|
|
}
|
|
|
|
TeamsOp TeamsOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<TeamsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TeamsOp TeamsOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult TeamsOp::verifyInvariantsImpl() {
|
|
auto tblgen_dyn_groupprivate_access_group = getProperties().dyn_groupprivate_access_group; (void)tblgen_dyn_groupprivate_access_group;
|
|
auto tblgen_dyn_groupprivate_fallback = getProperties().dyn_groupprivate_fallback; (void)tblgen_dyn_groupprivate_fallback;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_reduction_byref = getProperties().reduction_byref; (void)tblgen_reduction_byref;
|
|
auto tblgen_reduction_mod = getProperties().reduction_mod; (void)tblgen_reduction_mod;
|
|
auto tblgen_reduction_syms = getProperties().reduction_syms; (void)tblgen_reduction_syms;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps31(*this, tblgen_dyn_groupprivate_access_group, "dyn_groupprivate_access_group")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps32(*this, tblgen_dyn_groupprivate_fallback, "dyn_groupprivate_fallback")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_private_syms, "private_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_private_needs_barrier, "private_needs_barrier")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps19(*this, tblgen_reduction_mod, "reduction_mod")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(*this, tblgen_reduction_byref, "reduction_byref")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_reduction_syms, "reduction_syms")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*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_OpenMPOps6(*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_OpenMPOps8(*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_OpenMPOps2(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup5 = getODSOperands(5);
|
|
|
|
for (auto v : valueGroup5) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps14(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup6 = getODSOperands(6);
|
|
|
|
for (auto v : valueGroup6) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup7 = getODSOperands(7);
|
|
|
|
for (auto v : valueGroup7) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup8 = getODSOperands(8);
|
|
|
|
for (auto v : valueGroup8) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps14(*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_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TeamsOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult TeamsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocate_varsOperands;
|
|
::llvm::SMLoc allocate_varsOperandsLoc;
|
|
(void)allocate_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocate_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocator_varsOperands;
|
|
::llvm::SMLoc allocator_varsOperandsLoc;
|
|
(void)allocator_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocator_varsTypes;
|
|
::mlir::omp::AccessGroupModifierAttr dyn_groupprivate_access_groupAttr;
|
|
::mlir::omp::FallbackModifierAttr dyn_groupprivate_fallbackAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dyn_groupprivate_sizeOperands;
|
|
::llvm::SMLoc dyn_groupprivate_sizeOperandsLoc;
|
|
(void)dyn_groupprivate_sizeOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> dyn_groupprivate_sizeTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> if_exprOperands;
|
|
::llvm::SMLoc if_exprOperandsLoc;
|
|
(void)if_exprOperandsLoc;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> num_teams_lowerOperands;
|
|
::llvm::SMLoc num_teams_lowerOperandsLoc;
|
|
(void)num_teams_lowerOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> num_teams_lowerTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> num_teams_upper_varsOperands;
|
|
::llvm::SMLoc num_teams_upper_varsOperandsLoc;
|
|
(void)num_teams_upper_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> num_teams_upper_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> thread_limit_varsOperands;
|
|
::llvm::SMLoc thread_limit_varsOperandsLoc;
|
|
(void)thread_limit_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> thread_limit_varsTypes;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> private_varsOperands;
|
|
::llvm::SMLoc private_varsOperandsLoc;
|
|
(void)private_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> private_varsTypes;
|
|
::mlir::ArrayAttr private_symsAttr;
|
|
::mlir::UnitAttr private_needs_barrierAttr;
|
|
::mlir::omp::ReductionModifierAttr reduction_modAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> reduction_varsOperands;
|
|
::llvm::SMLoc reduction_varsOperandsLoc;
|
|
(void)reduction_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> reduction_varsTypes;
|
|
::mlir::DenseBoolArrayAttr reduction_byrefAttr;
|
|
::mlir::ArrayAttr reduction_symsAttr;
|
|
bool allocateClause = false;
|
|
bool dyn_groupprivateClause = false;
|
|
bool ifClause = false;
|
|
bool num_teamsClause = false;
|
|
bool thread_limitClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("allocate"))) {
|
|
|
|
if (allocateClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`allocate` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
allocateClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
allocate_varsOperandsLoc = parser.getCurrentLocation();
|
|
allocator_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseAllocateAndAllocator(parser, allocate_varsOperands, allocate_varsTypes, allocator_varsOperands, allocator_varsTypes);
|
|
if (odsResult) return ::mlir::failure();
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("dyn_groupprivate"))) {
|
|
|
|
if (dyn_groupprivateClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`dyn_groupprivate` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
dyn_groupprivateClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
dyn_groupprivate_sizeOperandsLoc = parser.getCurrentLocation();
|
|
::std::optional<::mlir::OpAsmParser::UnresolvedOperand> dyn_groupprivate_sizeOperand;
|
|
::mlir::Type dyn_groupprivate_sizeType;
|
|
auto odsResult = parseDynGroupprivateClause(parser, dyn_groupprivate_access_groupAttr, dyn_groupprivate_fallbackAttr, dyn_groupprivate_sizeOperand, dyn_groupprivate_sizeType);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (dyn_groupprivate_access_groupAttr)
|
|
result.getOrAddProperties<TeamsOp::Properties>().dyn_groupprivate_access_group = dyn_groupprivate_access_groupAttr;
|
|
if (dyn_groupprivate_fallbackAttr)
|
|
result.getOrAddProperties<TeamsOp::Properties>().dyn_groupprivate_fallback = dyn_groupprivate_fallbackAttr;
|
|
if (dyn_groupprivate_sizeOperand.has_value())
|
|
dyn_groupprivate_sizeOperands.push_back(*dyn_groupprivate_sizeOperand);
|
|
if (dyn_groupprivate_sizeType)
|
|
dyn_groupprivate_sizeTypes.push_back(dyn_groupprivate_sizeType);
|
|
}
|
|
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();
|
|
|
|
{
|
|
if_exprOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
if_exprOperands.push_back(operand);
|
|
}
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("num_teams"))) {
|
|
|
|
if (num_teamsClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`num_teams` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
num_teamsClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
num_teams_lowerOperandsLoc = parser.getCurrentLocation();
|
|
::mlir::OpAsmParser::UnresolvedOperand operand;
|
|
::mlir::OptionalParseResult parseResult =
|
|
parser.parseOptionalOperand(operand);
|
|
if (parseResult.has_value()) {
|
|
if (failed(*parseResult))
|
|
return ::mlir::failure();
|
|
num_teams_lowerOperands.push_back(operand);
|
|
}
|
|
}
|
|
if (!num_teams_lowerOperands.empty()) {
|
|
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();
|
|
num_teams_lowerTypes.push_back(optionalType);
|
|
}
|
|
}
|
|
}
|
|
if (parser.parseKeyword("to"))
|
|
return ::mlir::failure();
|
|
|
|
num_teams_upper_varsOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(num_teams_upper_varsOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(num_teams_upper_varsTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("thread_limit"))) {
|
|
|
|
if (thread_limitClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`thread_limit` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
thread_limitClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
thread_limit_varsOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(thread_limit_varsOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(thread_limit_varsTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
{
|
|
private_varsOperandsLoc = parser.getCurrentLocation();
|
|
reduction_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parsePrivateReductionRegion(parser, *regionRegion, private_varsOperands, private_varsTypes, private_symsAttr, private_needs_barrierAttr, reduction_modAttr, reduction_varsOperands, reduction_varsTypes, reduction_byrefAttr, reduction_symsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (private_symsAttr)
|
|
result.getOrAddProperties<TeamsOp::Properties>().private_syms = private_symsAttr;
|
|
if (private_needs_barrierAttr)
|
|
result.getOrAddProperties<TeamsOp::Properties>().private_needs_barrier = private_needs_barrierAttr;
|
|
if (reduction_modAttr)
|
|
result.getOrAddProperties<TeamsOp::Properties>().reduction_mod = reduction_modAttr;
|
|
if (reduction_byrefAttr)
|
|
result.getOrAddProperties<TeamsOp::Properties>().reduction_byref = reduction_byrefAttr;
|
|
if (reduction_symsAttr)
|
|
result.getOrAddProperties<TeamsOp::Properties>().reduction_syms = reduction_symsAttr;
|
|
}
|
|
{
|
|
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<int32_t>({static_cast<int32_t>(allocate_varsOperands.size()), static_cast<int32_t>(allocator_varsOperands.size()), static_cast<int32_t>(dyn_groupprivate_sizeOperands.size()), static_cast<int32_t>(if_exprOperands.size()), static_cast<int32_t>(num_teams_lowerOperands.size()), static_cast<int32_t>(num_teams_upper_varsOperands.size()), static_cast<int32_t>(private_varsOperands.size()), static_cast<int32_t>(reduction_varsOperands.size()), static_cast<int32_t>(thread_limit_varsOperands.size())}), result.getOrAddProperties<TeamsOp::Properties>().operandSegmentSizes.begin());
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1);
|
|
if (parser.resolveOperands(allocate_varsOperands, allocate_varsTypes, allocate_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(allocator_varsOperands, allocator_varsTypes, allocator_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!dyn_groupprivate_sizeOperands.empty()) {
|
|
if (parser.resolveOperands(dyn_groupprivate_sizeOperands, dyn_groupprivate_sizeTypes, dyn_groupprivate_sizeOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (!if_exprOperands.empty()) {
|
|
if (parser.resolveOperands(if_exprOperands, odsBuildableType0, if_exprOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (!num_teams_lowerOperands.empty()) {
|
|
if (parser.resolveOperands(num_teams_lowerOperands, num_teams_lowerTypes, num_teams_lowerOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(num_teams_upper_varsOperands, num_teams_upper_varsTypes, num_teams_upper_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(private_varsOperands, private_varsTypes, private_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(reduction_varsOperands, reduction_varsTypes, reduction_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(thread_limit_varsOperands, thread_limit_varsTypes, thread_limit_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TeamsOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getAllocateVars().size() || getAllocatorVars().size()) {
|
|
_odsPrinter << ' ' << "allocate";
|
|
_odsPrinter << "(";
|
|
printAllocateAndAllocator(_odsPrinter, *this, getAllocateVars(), getAllocateVars().getTypes(), getAllocatorVars(), getAllocatorVars().getTypes());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getDynGroupprivateAccessGroupAttr()) || (getDynGroupprivateFallbackAttr()) || getDynGroupprivateSize()) {
|
|
_odsPrinter << ' ' << "dyn_groupprivate";
|
|
_odsPrinter << "(";
|
|
printDynGroupprivateClause(_odsPrinter, *this, getDynGroupprivateAccessGroupAttr(), getDynGroupprivateFallbackAttr(), getDynGroupprivateSize(), (getDynGroupprivateSize() ? getDynGroupprivateSize().getType() : ::mlir::Type()));
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getIfExpr()) {
|
|
_odsPrinter << ' ' << "if";
|
|
_odsPrinter << "(";
|
|
if (::mlir::Value value = getIfExpr())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getNumTeamsLower() || getNumTeamsUpperVars().size()) {
|
|
_odsPrinter << ' ' << "num_teams";
|
|
_odsPrinter << "(";
|
|
if (getNumTeamsLower()) {
|
|
if (::mlir::Value value = getNumTeamsLower())
|
|
_odsPrinter << value;
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << (getNumTeamsLower() ? ::llvm::ArrayRef<::mlir::Type>(getNumTeamsLower().getType()) : ::llvm::ArrayRef<::mlir::Type>());
|
|
}
|
|
_odsPrinter << ' ' << "to";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getNumTeamsUpperVars();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getNumTeamsUpperVars().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getThreadLimitVars().size()) {
|
|
_odsPrinter << ' ' << "thread_limit";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getThreadLimitVars();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getThreadLimitVars().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ';
|
|
printPrivateReductionRegion(_odsPrinter, *this, getRegion(), getPrivateVars(), getPrivateVars().getTypes(), getPrivateSymsAttr(), getPrivateNeedsBarrierAttr(), getReductionModAttr(), getReductionVars(), getReductionVars().getTypes(), getReductionByrefAttr(), getReductionSymsAttr());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("dyn_groupprivate_access_group");
|
|
elidedAttrs.push_back("dyn_groupprivate_fallback");
|
|
elidedAttrs.push_back("private_syms");
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
elidedAttrs.push_back("reduction_mod");
|
|
elidedAttrs.push_back("reduction_byref");
|
|
elidedAttrs.push_back("reduction_syms");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getPrivateNeedsBarrierAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::TeamsOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::TeamsOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::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<mlir::Attribute> 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<TerminatorOp>(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<decltype(resultTypes)>(resultTypes));
|
|
auto __res__ = ::llvm::dyn_cast<TerminatorOp>(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<decltype(resultTypes)>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<TerminatorOp>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(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&>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<TerminatorOp>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(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::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::TerminatorOp)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::ThreadprivateOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ThreadprivateOpGenericAdaptorBase::ThreadprivateOpGenericAdaptorBase(ThreadprivateOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
ThreadprivateOpAdaptor::ThreadprivateOpAdaptor(ThreadprivateOp op) : ThreadprivateOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ThreadprivateOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ThreadprivateOp::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 ThreadprivateOp::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 ThreadprivateOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ThreadprivateOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ThreadprivateOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void ThreadprivateOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult ThreadprivateOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ThreadprivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type tls_addr, ::mlir::Value sym_addr) {
|
|
odsState.addOperands(sym_addr);
|
|
odsState.addTypes(tls_addr);
|
|
}
|
|
|
|
ThreadprivateOp ThreadprivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type tls_addr, ::mlir::Value sym_addr) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(tls_addr)>(tls_addr), std::forward<decltype(sym_addr)>(sym_addr));
|
|
auto __res__ = ::llvm::dyn_cast<ThreadprivateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ThreadprivateOp ThreadprivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type tls_addr, ::mlir::Value sym_addr) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(tls_addr)>(tls_addr), std::forward<decltype(sym_addr)>(sym_addr));
|
|
}
|
|
|
|
void ThreadprivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value sym_addr) {
|
|
odsState.addOperands(sym_addr);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ThreadprivateOp ThreadprivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value sym_addr) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_addr)>(sym_addr));
|
|
auto __res__ = ::llvm::dyn_cast<ThreadprivateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ThreadprivateOp ThreadprivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value sym_addr) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_addr)>(sym_addr));
|
|
}
|
|
|
|
void ThreadprivateOp::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);
|
|
}
|
|
|
|
ThreadprivateOp ThreadprivateOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<ThreadprivateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ThreadprivateOp ThreadprivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void ThreadprivateOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ThreadprivateOp ThreadprivateOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<ThreadprivateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ThreadprivateOp ThreadprivateOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult ThreadprivateOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps1(*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_OpenMPOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType()))))
|
|
return emitOpError("failed to verify that all of {sym_addr, tls_addr} have same type");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ThreadprivateOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult ThreadprivateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::OpAsmParser::UnresolvedOperand sym_addrRawOperand{};
|
|
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sym_addrOperands(&sym_addrRawOperand, 1); ::llvm::SMLoc sym_addrOperandsLoc;
|
|
(void)sym_addrOperandsLoc;
|
|
::mlir::Type sym_addrRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> sym_addrTypes(&sym_addrRawType, 1);
|
|
::mlir::Type tls_addrRawType{};
|
|
::llvm::ArrayRef<::mlir::Type> tls_addrTypes(&tls_addrRawType, 1);
|
|
|
|
sym_addrOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperand(sym_addrRawOperand))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
::mlir::omp::PointerLikeType type;
|
|
if (parser.parseCustomTypeWithFallback(type))
|
|
return ::mlir::failure();
|
|
sym_addrRawType = type;
|
|
}
|
|
if (parser.parseArrow())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
::mlir::omp::PointerLikeType type;
|
|
if (parser.parseCustomTypeWithFallback(type))
|
|
return ::mlir::failure();
|
|
tls_addrRawType = type;
|
|
}
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
|
|
return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
|
|
})))
|
|
return ::mlir::failure();
|
|
}
|
|
result.addTypes(tls_addrTypes);
|
|
if (parser.resolveOperands(sym_addrOperands, sym_addrTypes, sym_addrOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ThreadprivateOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getSymAddr();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
{
|
|
auto type = getSymAddr().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::omp::PointerLikeType>(type))
|
|
_odsPrinter.printStrippedAttrOrType(validType);
|
|
else
|
|
_odsPrinter << type;
|
|
}
|
|
_odsPrinter << ' ' << "->";
|
|
_odsPrinter << ' ';
|
|
{
|
|
auto type = getTlsAddr().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::omp::PointerLikeType>(type))
|
|
_odsPrinter.printStrippedAttrOrType(validType);
|
|
else
|
|
_odsPrinter << type;
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::ThreadprivateOp)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::TileOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TileOpGenericAdaptorBase::TileOpGenericAdaptorBase(TileOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> TileOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
TileOpAdaptor::TileOpAdaptor(TileOp op) : TileOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TileOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> TileOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange TileOp::getGenerateesMutable() {
|
|
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 TileOp::getApplyeesMutable() {
|
|
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 TileOp::getSizesMutable() {
|
|
auto range = getODSOperandIndexAndLength(2);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)}));
|
|
return mutableRange;
|
|
}
|
|
|
|
::llvm::LogicalResult TileOp::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 TileOp::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 TileOp::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<mlir::Attribute> TileOp::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 TileOp::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 TileOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult TileOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TileOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(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 TileOp::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 TileOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange generatees, ::mlir::ValueRange applyees, ::mlir::ValueRange sizes) {
|
|
odsState.addOperands(generatees);
|
|
odsState.addOperands(applyees);
|
|
odsState.addOperands(sizes);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(generatees.size()), static_cast<int32_t>(applyees.size()), static_cast<int32_t>(sizes.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
}
|
|
|
|
TileOp TileOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange generatees, ::mlir::ValueRange applyees, ::mlir::ValueRange sizes) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(generatees)>(generatees), std::forward<decltype(applyees)>(applyees), std::forward<decltype(sizes)>(sizes));
|
|
auto __res__ = ::llvm::dyn_cast<TileOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TileOp TileOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange generatees, ::mlir::ValueRange applyees, ::mlir::ValueRange sizes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(generatees)>(generatees), std::forward<decltype(applyees)>(applyees), std::forward<decltype(sizes)>(sizes));
|
|
}
|
|
|
|
void TileOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange generatees, ::mlir::ValueRange applyees, ::mlir::ValueRange sizes) {
|
|
odsState.addOperands(generatees);
|
|
odsState.addOperands(applyees);
|
|
odsState.addOperands(sizes);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(generatees.size()), static_cast<int32_t>(applyees.size()), static_cast<int32_t>(sizes.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TileOp TileOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange generatees, ::mlir::ValueRange applyees, ::mlir::ValueRange sizes) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(generatees)>(generatees), std::forward<decltype(applyees)>(applyees), std::forward<decltype(sizes)>(sizes));
|
|
auto __res__ = ::llvm::dyn_cast<TileOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TileOp TileOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange generatees, ::mlir::ValueRange applyees, ::mlir::ValueRange sizes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(generatees)>(generatees), std::forward<decltype(applyees)>(applyees), std::forward<decltype(sizes)>(sizes));
|
|
}
|
|
|
|
void TileOp::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<TileOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
TileOp TileOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<TileOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TileOp TileOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void TileOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TileOp TileOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<TileOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TileOp TileOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult TileOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps13(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps13(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps14(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TileOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult TileOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> generateesOperands;
|
|
::llvm::SMLoc generateesOperandsLoc;
|
|
(void)generateesOperandsLoc;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> applyeesOperands;
|
|
::llvm::SMLoc applyeesOperandsLoc;
|
|
(void)applyeesOperandsLoc;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> sizesOperands;
|
|
::llvm::SMLoc sizesOperandsLoc;
|
|
(void)sizesOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> sizesTypes;
|
|
{
|
|
generateesOperandsLoc = parser.getCurrentLocation();
|
|
applyeesOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseLoopTransformClis(parser, generateesOperands, applyeesOperands);
|
|
if (odsResult) return ::mlir::failure();
|
|
}
|
|
bool sizesClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("sizes"))) {
|
|
|
|
if (sizesClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`sizes` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
sizesClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
sizesOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(sizesOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(sizesTypes))
|
|
return ::mlir::failure();
|
|
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<int32_t>({static_cast<int32_t>(generateesOperands.size()), static_cast<int32_t>(applyeesOperands.size()), static_cast<int32_t>(sizesOperands.size())}), result.getOrAddProperties<TileOp::Properties>().operandSegmentSizes.begin());
|
|
::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::omp::CanonicalLoopInfoType>();
|
|
if (parser.resolveOperands(generateesOperands, odsBuildableType0, generateesOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(applyeesOperands, odsBuildableType0, applyeesOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(sizesOperands, sizesTypes, sizesOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TileOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
printLoopTransformClis(_odsPrinter, *this, getGeneratees(), getApplyees());
|
|
if (false || getSizes().size()) {
|
|
_odsPrinter << ' ' << "sizes";
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getSizes();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getSizes().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::TileOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::TileOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::UnrollHeuristicOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
UnrollHeuristicOpGenericAdaptorBase::UnrollHeuristicOpGenericAdaptorBase(UnrollHeuristicOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
UnrollHeuristicOpAdaptor::UnrollHeuristicOpAdaptor(UnrollHeuristicOp op) : UnrollHeuristicOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult UnrollHeuristicOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult UnrollHeuristicOp::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 UnrollHeuristicOp::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 UnrollHeuristicOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> UnrollHeuristicOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void UnrollHeuristicOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void UnrollHeuristicOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult UnrollHeuristicOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
UnrollHeuristicOp UnrollHeuristicOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value cli) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(cli)>(cli));
|
|
auto __res__ = ::llvm::dyn_cast<UnrollHeuristicOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
UnrollHeuristicOp UnrollHeuristicOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value cli) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(cli)>(cli));
|
|
}
|
|
|
|
void UnrollHeuristicOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value applyee) {
|
|
odsState.addOperands(applyee);
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
UnrollHeuristicOp UnrollHeuristicOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value applyee) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(applyee)>(applyee));
|
|
auto __res__ = ::llvm::dyn_cast<UnrollHeuristicOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
UnrollHeuristicOp UnrollHeuristicOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value applyee) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(applyee)>(applyee));
|
|
}
|
|
|
|
void UnrollHeuristicOp::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);
|
|
}
|
|
|
|
UnrollHeuristicOp UnrollHeuristicOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<UnrollHeuristicOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
UnrollHeuristicOp UnrollHeuristicOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void UnrollHeuristicOp::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&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
UnrollHeuristicOp UnrollHeuristicOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<UnrollHeuristicOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
UnrollHeuristicOp UnrollHeuristicOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult UnrollHeuristicOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps9(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult UnrollHeuristicOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::llvm::LogicalResult UnrollHeuristicOp::setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
|
|
if (!dict) {
|
|
emitError() << "expected DictionaryAttr to set properties";
|
|
return ::mlir::failure();
|
|
}
|
|
// keep track of used keys in the input dictionary to be able to error out
|
|
// if there are some unknown ones.
|
|
::mlir::DenseSet<::mlir::StringAttr> usedKeys;
|
|
::mlir::MLIRContext *ctx = dict.getContext();
|
|
(void)ctx;
|
|
|
|
for (::mlir::NamedAttribute attr : dict) {
|
|
if (!usedKeys.contains(attr.getName()))
|
|
return emitError() << "unknown key '" << attr.getName() <<
|
|
"' when parsing properties dictionary";
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::UnrollHeuristicOp)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::WorkdistributeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
WorkdistributeOpGenericAdaptorBase::WorkdistributeOpGenericAdaptorBase(WorkdistributeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
WorkdistributeOpAdaptor::WorkdistributeOpAdaptor(WorkdistributeOp op) : WorkdistributeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult WorkdistributeOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult WorkdistributeOp::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 WorkdistributeOp::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 WorkdistributeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> WorkdistributeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void WorkdistributeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void WorkdistributeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult WorkdistributeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void WorkdistributeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) {
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
WorkdistributeOp WorkdistributeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__);
|
|
auto __res__ = ::llvm::dyn_cast<WorkdistributeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WorkdistributeOp WorkdistributeOp::create(::mlir::ImplicitLocOpBuilder &builder) {
|
|
return create(builder, builder.getLoc());
|
|
}
|
|
|
|
void WorkdistributeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) {
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
WorkdistributeOp WorkdistributeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes));
|
|
auto __res__ = ::llvm::dyn_cast<WorkdistributeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WorkdistributeOp WorkdistributeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes));
|
|
}
|
|
|
|
void WorkdistributeOp::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);
|
|
}
|
|
|
|
WorkdistributeOp WorkdistributeOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<WorkdistributeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WorkdistributeOp WorkdistributeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void WorkdistributeOp::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&>(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);
|
|
}
|
|
|
|
WorkdistributeOp WorkdistributeOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<WorkdistributeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WorkdistributeOp WorkdistributeOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult WorkdistributeOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult WorkdistributeOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult WorkdistributeOp::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 WorkdistributeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getRegion());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::WorkdistributeOp)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::WorkshareLoopWrapperOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
WorkshareLoopWrapperOpGenericAdaptorBase::WorkshareLoopWrapperOpGenericAdaptorBase(WorkshareLoopWrapperOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
WorkshareLoopWrapperOpAdaptor::WorkshareLoopWrapperOpAdaptor(WorkshareLoopWrapperOp op) : WorkshareLoopWrapperOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult WorkshareLoopWrapperOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult WorkshareLoopWrapperOp::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 WorkshareLoopWrapperOp::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 WorkshareLoopWrapperOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> WorkshareLoopWrapperOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void WorkshareLoopWrapperOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void WorkshareLoopWrapperOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult WorkshareLoopWrapperOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void WorkshareLoopWrapperOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) {
|
|
build(odsBuilder, odsState, {});
|
|
}
|
|
|
|
WorkshareLoopWrapperOp WorkshareLoopWrapperOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__);
|
|
auto __res__ = ::llvm::dyn_cast<WorkshareLoopWrapperOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WorkshareLoopWrapperOp WorkshareLoopWrapperOp::create(::mlir::ImplicitLocOpBuilder &builder) {
|
|
return create(builder, builder.getLoc());
|
|
}
|
|
|
|
void WorkshareLoopWrapperOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) {
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
WorkshareLoopWrapperOp WorkshareLoopWrapperOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes));
|
|
auto __res__ = ::llvm::dyn_cast<WorkshareLoopWrapperOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WorkshareLoopWrapperOp WorkshareLoopWrapperOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes));
|
|
}
|
|
|
|
void WorkshareLoopWrapperOp::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);
|
|
}
|
|
|
|
WorkshareLoopWrapperOp WorkshareLoopWrapperOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<WorkshareLoopWrapperOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WorkshareLoopWrapperOp WorkshareLoopWrapperOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void WorkshareLoopWrapperOp::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&>(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);
|
|
}
|
|
|
|
WorkshareLoopWrapperOp WorkshareLoopWrapperOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<WorkshareLoopWrapperOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WorkshareLoopWrapperOp WorkshareLoopWrapperOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult WorkshareLoopWrapperOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult WorkshareLoopWrapperOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult WorkshareLoopWrapperOp::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();
|
|
|
|
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));
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void WorkshareLoopWrapperOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getRegion());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::WorkshareLoopWrapperOp)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::WorkshareOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
WorkshareOpGenericAdaptorBase::WorkshareOpGenericAdaptorBase(WorkshareOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::UnitAttr WorkshareOpGenericAdaptorBase::getNowaitAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nowait);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool WorkshareOpGenericAdaptorBase::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
WorkshareOpAdaptor::WorkshareOpAdaptor(WorkshareOp op) : WorkshareOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult WorkshareOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
|
|
if (tblgen_nowait && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nowait))))
|
|
return emitError(loc, "'omp.workshare' op attribute 'nowait' failed to satisfy constraint: unit attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult WorkshareOp::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.nowait;
|
|
auto attr = dict.get("nowait");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nowait` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute WorkshareOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.nowait;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nowait",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code WorkshareOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.nowait.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> WorkshareOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "nowait")
|
|
return prop.nowait;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void WorkshareOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "nowait") {
|
|
prop.nowait = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nowait)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void WorkshareOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.nowait) attrs.append("nowait", prop.nowait);
|
|
}
|
|
|
|
::llvm::LogicalResult WorkshareOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNowaitAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "nowait", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult WorkshareOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nowait)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void WorkshareOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.nowait);
|
|
}
|
|
|
|
bool WorkshareOp::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
void WorkshareOp::setNowait(bool attrValue) {
|
|
auto &odsProp = getProperties().nowait;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
WorkshareOp WorkshareOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const WorkshareOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<WorkshareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WorkshareOp WorkshareOp::create(::mlir::ImplicitLocOpBuilder &builder, const WorkshareOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void WorkshareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::UnitAttr nowait) {
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
WorkshareOp WorkshareOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::UnitAttr nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<WorkshareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WorkshareOp WorkshareOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::UnitAttr nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void WorkshareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr nowait) {
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
WorkshareOp WorkshareOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<WorkshareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WorkshareOp WorkshareOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void WorkshareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/bool nowait) {
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
WorkshareOp WorkshareOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/bool nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<WorkshareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WorkshareOp WorkshareOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/bool nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void WorkshareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/bool nowait) {
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
WorkshareOp WorkshareOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/bool nowait) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(nowait)>(nowait));
|
|
auto __res__ = ::llvm::dyn_cast<WorkshareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WorkshareOp WorkshareOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/bool nowait) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(nowait)>(nowait));
|
|
}
|
|
|
|
void WorkshareOp::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<WorkshareOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
WorkshareOp WorkshareOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<WorkshareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WorkshareOp WorkshareOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void WorkshareOp::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&>(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);
|
|
}
|
|
|
|
WorkshareOp WorkshareOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<WorkshareOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WorkshareOp WorkshareOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult WorkshareOp::verifyInvariantsImpl() {
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_nowait, "nowait")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult WorkshareOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult WorkshareOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
bool nowaitClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("nowait"))) {
|
|
|
|
if (nowaitClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`nowait` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
nowaitClause = true;
|
|
result.getOrAddProperties<WorkshareOp::Properties>().nowait = parser.getBuilder().getUnitAttr(); } else {
|
|
break;
|
|
}
|
|
}
|
|
|
|
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 WorkshareOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || ((getNowaitAttr() && getNowaitAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "nowait";
|
|
}
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printRegion(getRegion());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("nowait");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getNowaitAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("nowait");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::WorkshareOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::WorkshareOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::WsloopOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
WsloopOpGenericAdaptorBase::WsloopOpGenericAdaptorBase(WsloopOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> WsloopOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > WsloopOpGenericAdaptorBase::getLinearVarTypes() {
|
|
auto attr = getLinearVarTypesAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > WsloopOpGenericAdaptorBase::getLinearModifiers() {
|
|
auto attr = getLinearModifiersAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr WsloopOpGenericAdaptorBase::getNowaitAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nowait);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool WsloopOpGenericAdaptorBase::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseOrderKind> WsloopOpGenericAdaptorBase::getOrder() {
|
|
auto attr = getOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::OrderModifier> WsloopOpGenericAdaptorBase::getOrderMod() {
|
|
auto attr = getOrderModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::OrderModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<uint64_t> WsloopOpGenericAdaptorBase::getOrdered() {
|
|
auto attr = getOrderedAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > WsloopOpGenericAdaptorBase::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr WsloopOpGenericAdaptorBase::getPrivateNeedsBarrierAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().private_needs_barrier);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool WsloopOpGenericAdaptorBase::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ReductionModifier> WsloopOpGenericAdaptorBase::getReductionMod() {
|
|
auto attr = getReductionModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ReductionModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> WsloopOpGenericAdaptorBase::getReductionByref() {
|
|
auto attr = getReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > WsloopOpGenericAdaptorBase::getReductionSyms() {
|
|
auto attr = getReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseScheduleKind> WsloopOpGenericAdaptorBase::getScheduleKind() {
|
|
auto attr = getScheduleKindAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseScheduleKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ScheduleModifier> WsloopOpGenericAdaptorBase::getScheduleMod() {
|
|
auto attr = getScheduleModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ScheduleModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::mlir::UnitAttr WsloopOpGenericAdaptorBase::getScheduleSimdAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().schedule_simd);
|
|
if (!attr)
|
|
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
|
|
return attr;
|
|
}
|
|
|
|
bool WsloopOpGenericAdaptorBase::getScheduleSimd() {
|
|
auto attr = getScheduleSimdAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
WsloopOpAdaptor::WsloopOpAdaptor(WsloopOp op) : WsloopOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult WsloopOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_linear_modifiers = getProperties().linear_modifiers; (void)tblgen_linear_modifiers;
|
|
auto tblgen_linear_var_types = getProperties().linear_var_types; (void)tblgen_linear_var_types;
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
auto tblgen_order = getProperties().order; (void)tblgen_order;
|
|
auto tblgen_order_mod = getProperties().order_mod; (void)tblgen_order_mod;
|
|
auto tblgen_ordered = getProperties().ordered; (void)tblgen_ordered;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_reduction_byref = getProperties().reduction_byref; (void)tblgen_reduction_byref;
|
|
auto tblgen_reduction_mod = getProperties().reduction_mod; (void)tblgen_reduction_mod;
|
|
auto tblgen_reduction_syms = getProperties().reduction_syms; (void)tblgen_reduction_syms;
|
|
auto tblgen_schedule_kind = getProperties().schedule_kind; (void)tblgen_schedule_kind;
|
|
auto tblgen_schedule_mod = getProperties().schedule_mod; (void)tblgen_schedule_mod;
|
|
auto tblgen_schedule_simd = getProperties().schedule_simd; (void)tblgen_schedule_simd;
|
|
|
|
if (tblgen_linear_var_types && !((::llvm::isa<::mlir::ArrayAttr>(tblgen_linear_var_types))))
|
|
return emitError(loc, "'omp.wsloop' op attribute 'linear_var_types' failed to satisfy constraint: array attribute");
|
|
|
|
if (tblgen_linear_modifiers && !((::llvm::isa<::mlir::ArrayAttr>(tblgen_linear_modifiers))))
|
|
return emitError(loc, "'omp.wsloop' op attribute 'linear_modifiers' failed to satisfy constraint: array attribute");
|
|
|
|
if (tblgen_nowait && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nowait))))
|
|
return emitError(loc, "'omp.wsloop' op attribute 'nowait' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_order && !((::llvm::isa<::mlir::omp::ClauseOrderKindAttr>(tblgen_order))))
|
|
return emitError(loc, "'omp.wsloop' op attribute 'order' failed to satisfy constraint: OrderKind Clause");
|
|
|
|
if (tblgen_order_mod && !((::llvm::isa<::mlir::omp::OrderModifierAttr>(tblgen_order_mod))))
|
|
return emitError(loc, "'omp.wsloop' op attribute 'order_mod' failed to satisfy constraint: OpenMP Order Modifier");
|
|
|
|
if (tblgen_ordered && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_ordered))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_ordered).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_ordered).getInt() >= 0))))
|
|
return emitError(loc, "'omp.wsloop' op attribute 'ordered' failed to satisfy constraint: 64-bit signless integer attribute whose minimum value is 0");
|
|
|
|
if (tblgen_private_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_private_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_private_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.wsloop' op attribute 'private_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_private_needs_barrier && !((::llvm::isa<::mlir::UnitAttr>(tblgen_private_needs_barrier))))
|
|
return emitError(loc, "'omp.wsloop' op attribute 'private_needs_barrier' failed to satisfy constraint: unit attribute");
|
|
|
|
if (tblgen_reduction_mod && !((::llvm::isa<::mlir::omp::ReductionModifierAttr>(tblgen_reduction_mod))))
|
|
return emitError(loc, "'omp.wsloop' op attribute 'reduction_mod' failed to satisfy constraint: reduction modifier");
|
|
|
|
if (tblgen_reduction_byref && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(tblgen_reduction_byref))))
|
|
return emitError(loc, "'omp.wsloop' op attribute 'reduction_byref' failed to satisfy constraint: i1 dense array attribute");
|
|
|
|
if (tblgen_reduction_syms && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_reduction_syms))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_reduction_syms), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); }))))
|
|
return emitError(loc, "'omp.wsloop' op attribute 'reduction_syms' failed to satisfy constraint: symbol ref array attribute");
|
|
|
|
if (tblgen_schedule_kind && !((::llvm::isa<::mlir::omp::ClauseScheduleKindAttr>(tblgen_schedule_kind))))
|
|
return emitError(loc, "'omp.wsloop' op attribute 'schedule_kind' failed to satisfy constraint: ScheduleKind Clause");
|
|
|
|
if (tblgen_schedule_mod && !((::llvm::isa<::mlir::omp::ScheduleModifierAttr>(tblgen_schedule_mod))))
|
|
return emitError(loc, "'omp.wsloop' op attribute 'schedule_mod' failed to satisfy constraint: OpenMP Schedule Modifier");
|
|
|
|
if (tblgen_schedule_simd && !((::llvm::isa<::mlir::UnitAttr>(tblgen_schedule_simd))))
|
|
return emitError(loc, "'omp.wsloop' op attribute 'schedule_simd' failed to satisfy constraint: unit attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> WsloopOp::getODSOperandIndexAndLength(unsigned index) {
|
|
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
|
|
|
|
unsigned start = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
start += sizeAttr[i];
|
|
return {start, sizeAttr[index]};
|
|
}
|
|
|
|
::mlir::MutableOperandRange WsloopOp::getAllocateVarsMutable() {
|
|
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 WsloopOp::getAllocatorVarsMutable() {
|
|
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 WsloopOp::getLinearVarsMutable() {
|
|
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 WsloopOp::getLinearStepVarsMutable() {
|
|
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 WsloopOp::getPrivateVarsMutable() {
|
|
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 WsloopOp::getReductionVarsMutable() {
|
|
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 WsloopOp::getScheduleChunkMutable() {
|
|
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;
|
|
}
|
|
|
|
::llvm::LogicalResult WsloopOp::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.linear_modifiers;
|
|
auto attr = dict.get("linear_modifiers");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `linear_modifiers` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.linear_var_types;
|
|
auto attr = dict.get("linear_var_types");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `linear_var_types` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.nowait;
|
|
auto attr = dict.get("nowait");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nowait` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.order;
|
|
auto attr = dict.get("order");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `order` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.order_mod;
|
|
auto attr = dict.get("order_mod");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `order_mod` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.ordered;
|
|
auto attr = dict.get("ordered");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `ordered` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_needs_barrier;
|
|
auto attr = dict.get("private_needs_barrier");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_needs_barrier` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.private_syms;
|
|
auto attr = dict.get("private_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `private_syms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_byref;
|
|
auto attr = dict.get("reduction_byref");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_byref` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_mod;
|
|
auto attr = dict.get("reduction_mod");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_mod` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.reduction_syms;
|
|
auto attr = dict.get("reduction_syms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `reduction_syms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.schedule_kind;
|
|
auto attr = dict.get("schedule_kind");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `schedule_kind` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.schedule_mod;
|
|
auto attr = dict.get("schedule_mod");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `schedule_mod` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.schedule_simd;
|
|
auto attr = dict.get("schedule_simd");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `schedule_simd` 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 WsloopOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.linear_modifiers;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("linear_modifiers",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.linear_var_types;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("linear_var_types",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.nowait;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nowait",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.order;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("order",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.order_mod;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("order_mod",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.ordered;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("ordered",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_needs_barrier;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_needs_barrier",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.private_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("private_syms",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_byref;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_byref",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_mod;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_mod",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.reduction_syms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("reduction_syms",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.schedule_kind;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("schedule_kind",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.schedule_mod;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("schedule_mod",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.schedule_simd;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("schedule_simd",
|
|
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 WsloopOp::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.linear_modifiers.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.linear_var_types.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.nowait.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.order.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.order_mod.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.ordered.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_needs_barrier.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.private_syms.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_byref.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_mod.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.reduction_syms.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.schedule_kind.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.schedule_mod.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.schedule_simd.getAsOpaquePointer()),
|
|
hash_operandSegmentSizes_(prop.operandSegmentSizes));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> WsloopOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "linear_modifiers")
|
|
return prop.linear_modifiers;
|
|
|
|
if (name == "linear_var_types")
|
|
return prop.linear_var_types;
|
|
|
|
if (name == "nowait")
|
|
return prop.nowait;
|
|
|
|
if (name == "order")
|
|
return prop.order;
|
|
|
|
if (name == "order_mod")
|
|
return prop.order_mod;
|
|
|
|
if (name == "ordered")
|
|
return prop.ordered;
|
|
|
|
if (name == "private_needs_barrier")
|
|
return prop.private_needs_barrier;
|
|
|
|
if (name == "private_syms")
|
|
return prop.private_syms;
|
|
|
|
if (name == "reduction_byref")
|
|
return prop.reduction_byref;
|
|
|
|
if (name == "reduction_mod")
|
|
return prop.reduction_mod;
|
|
|
|
if (name == "reduction_syms")
|
|
return prop.reduction_syms;
|
|
|
|
if (name == "schedule_kind")
|
|
return prop.schedule_kind;
|
|
|
|
if (name == "schedule_mod")
|
|
return prop.schedule_mod;
|
|
|
|
if (name == "schedule_simd")
|
|
return prop.schedule_simd;
|
|
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
|
|
return std::nullopt;
|
|
}
|
|
|
|
void WsloopOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "linear_modifiers") {
|
|
prop.linear_modifiers = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.linear_modifiers)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "linear_var_types") {
|
|
prop.linear_var_types = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.linear_var_types)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "nowait") {
|
|
prop.nowait = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nowait)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "order") {
|
|
prop.order = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.order)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "order_mod") {
|
|
prop.order_mod = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.order_mod)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "ordered") {
|
|
prop.ordered = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.ordered)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_needs_barrier") {
|
|
prop.private_needs_barrier = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_needs_barrier)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "private_syms") {
|
|
prop.private_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.private_syms)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_byref") {
|
|
prop.reduction_byref = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_byref)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_mod") {
|
|
prop.reduction_mod = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_mod)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "reduction_syms") {
|
|
prop.reduction_syms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.reduction_syms)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "schedule_kind") {
|
|
prop.schedule_kind = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.schedule_kind)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "schedule_mod") {
|
|
prop.schedule_mod = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.schedule_mod)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "schedule_simd") {
|
|
prop.schedule_simd = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.schedule_simd)>>(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 WsloopOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.linear_modifiers) attrs.append("linear_modifiers", prop.linear_modifiers);
|
|
|
|
if (prop.linear_var_types) attrs.append("linear_var_types", prop.linear_var_types);
|
|
|
|
if (prop.nowait) attrs.append("nowait", prop.nowait);
|
|
|
|
if (prop.order) attrs.append("order", prop.order);
|
|
|
|
if (prop.order_mod) attrs.append("order_mod", prop.order_mod);
|
|
|
|
if (prop.ordered) attrs.append("ordered", prop.ordered);
|
|
|
|
if (prop.private_needs_barrier) attrs.append("private_needs_barrier", prop.private_needs_barrier);
|
|
|
|
if (prop.private_syms) attrs.append("private_syms", prop.private_syms);
|
|
|
|
if (prop.reduction_byref) attrs.append("reduction_byref", prop.reduction_byref);
|
|
|
|
if (prop.reduction_mod) attrs.append("reduction_mod", prop.reduction_mod);
|
|
|
|
if (prop.reduction_syms) attrs.append("reduction_syms", prop.reduction_syms);
|
|
|
|
if (prop.schedule_kind) attrs.append("schedule_kind", prop.schedule_kind);
|
|
|
|
if (prop.schedule_mod) attrs.append("schedule_mod", prop.schedule_mod);
|
|
|
|
if (prop.schedule_simd) attrs.append("schedule_simd", prop.schedule_simd);
|
|
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
|
|
}
|
|
|
|
::llvm::LogicalResult WsloopOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getLinearModifiersAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps11(attr, "linear_modifiers", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getLinearVarTypesAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps11(attr, "linear_var_types", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNowaitAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "nowait", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getOrderAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps12(attr, "order", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getOrderModAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps13(attr, "order_mod", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getOrderedAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps26(attr, "ordered", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateNeedsBarrierAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "private_needs_barrier", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPrivateSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "private_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionByrefAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(attr, "reduction_byref", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionModAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps19(attr, "reduction_mod", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getReductionSymsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(attr, "reduction_syms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getScheduleKindAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps35(attr, "schedule_kind", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getScheduleModAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps36(attr, "schedule_mod", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getScheduleSimdAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(attr, "schedule_simd", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult WsloopOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.linear_modifiers)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.linear_var_types)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nowait)))
|
|
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<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
|
|
reader.emitError("size mismatch for operand/result_segment_size");
|
|
return ::mlir::failure();
|
|
}
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
|
|
}
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.order)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.order_mod)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.ordered)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_needs_barrier)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.private_syms)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_byref)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_mod)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.reduction_syms)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.schedule_kind)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.schedule_mod)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.schedule_simd)))
|
|
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 WsloopOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.linear_modifiers);
|
|
|
|
writer.writeOptionalAttribute(prop.linear_var_types);
|
|
|
|
writer.writeOptionalAttribute(prop.nowait);
|
|
|
|
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
|
|
}
|
|
|
|
writer.writeOptionalAttribute(prop.order);
|
|
|
|
writer.writeOptionalAttribute(prop.order_mod);
|
|
|
|
writer.writeOptionalAttribute(prop.ordered);
|
|
|
|
writer.writeOptionalAttribute(prop.private_needs_barrier);
|
|
|
|
writer.writeOptionalAttribute(prop.private_syms);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_byref);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_mod);
|
|
|
|
writer.writeOptionalAttribute(prop.reduction_syms);
|
|
|
|
writer.writeOptionalAttribute(prop.schedule_kind);
|
|
|
|
writer.writeOptionalAttribute(prop.schedule_mod);
|
|
|
|
writer.writeOptionalAttribute(prop.schedule_simd);
|
|
|
|
{
|
|
auto &propStorage = prop.operandSegmentSizes;
|
|
|
|
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
|
|
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
|
|
;
|
|
}
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > WsloopOp::getLinearVarTypes() {
|
|
auto attr = getLinearVarTypesAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > WsloopOp::getLinearModifiers() {
|
|
auto attr = getLinearModifiersAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool WsloopOp::getNowait() {
|
|
auto attr = getNowaitAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseOrderKind> WsloopOp::getOrder() {
|
|
auto attr = getOrderAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseOrderKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::OrderModifier> WsloopOp::getOrderMod() {
|
|
auto attr = getOrderModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::OrderModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<uint64_t> WsloopOp::getOrdered() {
|
|
auto attr = getOrderedAttr();
|
|
return attr ? ::std::optional<uint64_t>(attr.getValue().getZExtValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > WsloopOp::getPrivateSyms() {
|
|
auto attr = getPrivateSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
bool WsloopOp::getPrivateNeedsBarrier() {
|
|
auto attr = getPrivateNeedsBarrierAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ReductionModifier> WsloopOp::getReductionMod() {
|
|
auto attr = getReductionModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ReductionModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::llvm::ArrayRef<bool>> WsloopOp::getReductionByref() {
|
|
auto attr = getReductionByrefAttr();
|
|
return attr ? ::std::optional<::llvm::ArrayRef<bool>>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional< ::mlir::ArrayAttr > WsloopOp::getReductionSyms() {
|
|
auto attr = getReductionSymsAttr();
|
|
return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ClauseScheduleKind> WsloopOp::getScheduleKind() {
|
|
auto attr = getScheduleKindAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ClauseScheduleKind>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
::std::optional<::mlir::omp::ScheduleModifier> WsloopOp::getScheduleMod() {
|
|
auto attr = getScheduleModAttr();
|
|
return attr ? ::std::optional<::mlir::omp::ScheduleModifier>(attr.getValue()) : (::std::nullopt);
|
|
}
|
|
|
|
bool WsloopOp::getScheduleSimd() {
|
|
auto attr = getScheduleSimdAttr();
|
|
if (!attr)
|
|
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
|
|
return attr != nullptr;
|
|
}
|
|
|
|
void WsloopOp::setNowait(bool attrValue) {
|
|
auto &odsProp = getProperties().nowait;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void WsloopOp::setOrder(::std::optional<::mlir::omp::ClauseOrderKind> attrValue) {
|
|
auto &odsProp = getProperties().order;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ClauseOrderKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void WsloopOp::setOrderMod(::std::optional<::mlir::omp::OrderModifier> attrValue) {
|
|
auto &odsProp = getProperties().order_mod;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::OrderModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void WsloopOp::setOrdered(::std::optional<uint64_t> attrValue) {
|
|
auto &odsProp = getProperties().ordered;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void WsloopOp::setPrivateNeedsBarrier(bool attrValue) {
|
|
auto &odsProp = getProperties().private_needs_barrier;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void WsloopOp::setReductionMod(::std::optional<::mlir::omp::ReductionModifier> attrValue) {
|
|
auto &odsProp = getProperties().reduction_mod;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ReductionModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void WsloopOp::setReductionByref(::std::optional<::llvm::ArrayRef<bool>> attrValue) {
|
|
auto &odsProp = getProperties().reduction_byref;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getDenseBoolArrayAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void WsloopOp::setScheduleKind(::std::optional<::mlir::omp::ClauseScheduleKind> attrValue) {
|
|
auto &odsProp = getProperties().schedule_kind;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ClauseScheduleKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void WsloopOp::setScheduleMod(::std::optional<::mlir::omp::ScheduleModifier> attrValue) {
|
|
auto &odsProp = getProperties().schedule_mod;
|
|
if (attrValue)
|
|
odsProp = ::mlir::omp::ScheduleModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void WsloopOp::setScheduleSimd(bool attrValue) {
|
|
auto &odsProp = getProperties().schedule_simd;
|
|
if (attrValue)
|
|
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
WsloopOp WsloopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ArrayRef<NamedAttribute> attributes) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<WsloopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WsloopOp WsloopOp::create(::mlir::ImplicitLocOpBuilder &builder, ArrayRef<NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
WsloopOp WsloopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, const WsloopOperands &clauses) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(clauses)>(clauses));
|
|
auto __res__ = ::llvm::dyn_cast<WsloopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WsloopOp WsloopOp::create(::mlir::ImplicitLocOpBuilder &builder, const WsloopOperands &clauses) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(clauses)>(clauses));
|
|
}
|
|
|
|
void WsloopOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/::mlir::UnitAttr nowait, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::IntegerAttr ordered, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::omp::ClauseScheduleKindAttr schedule_kind, /*optional*/::mlir::Value schedule_chunk, /*optional*/::mlir::omp::ScheduleModifierAttr schedule_mod, /*optional*/::mlir::UnitAttr schedule_simd) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(linear_vars);
|
|
odsState.addOperands(linear_step_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
if (schedule_chunk)
|
|
odsState.addOperands(schedule_chunk);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(linear_vars.size()), static_cast<int32_t>(linear_step_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size()), (schedule_chunk ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (linear_var_types) {
|
|
odsState.getOrAddProperties<Properties>().linear_var_types = linear_var_types;
|
|
}
|
|
if (linear_modifiers) {
|
|
odsState.getOrAddProperties<Properties>().linear_modifiers = linear_modifiers;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
if (order) {
|
|
odsState.getOrAddProperties<Properties>().order = order;
|
|
}
|
|
if (order_mod) {
|
|
odsState.getOrAddProperties<Properties>().order_mod = order_mod;
|
|
}
|
|
if (ordered) {
|
|
odsState.getOrAddProperties<Properties>().ordered = ordered;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
if (schedule_kind) {
|
|
odsState.getOrAddProperties<Properties>().schedule_kind = schedule_kind;
|
|
}
|
|
if (schedule_mod) {
|
|
odsState.getOrAddProperties<Properties>().schedule_mod = schedule_mod;
|
|
}
|
|
if (schedule_simd) {
|
|
odsState.getOrAddProperties<Properties>().schedule_simd = schedule_simd;
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
WsloopOp WsloopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/::mlir::UnitAttr nowait, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::IntegerAttr ordered, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::omp::ClauseScheduleKindAttr schedule_kind, /*optional*/::mlir::Value schedule_chunk, /*optional*/::mlir::omp::ScheduleModifierAttr schedule_mod, /*optional*/::mlir::UnitAttr schedule_simd) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(nowait)>(nowait), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(ordered)>(ordered), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(schedule_kind)>(schedule_kind), std::forward<decltype(schedule_chunk)>(schedule_chunk), std::forward<decltype(schedule_mod)>(schedule_mod), std::forward<decltype(schedule_simd)>(schedule_simd));
|
|
auto __res__ = ::llvm::dyn_cast<WsloopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WsloopOp WsloopOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/::mlir::UnitAttr nowait, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::IntegerAttr ordered, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::omp::ClauseScheduleKindAttr schedule_kind, /*optional*/::mlir::Value schedule_chunk, /*optional*/::mlir::omp::ScheduleModifierAttr schedule_mod, /*optional*/::mlir::UnitAttr schedule_simd) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(nowait)>(nowait), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(ordered)>(ordered), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(schedule_kind)>(schedule_kind), std::forward<decltype(schedule_chunk)>(schedule_chunk), std::forward<decltype(schedule_mod)>(schedule_mod), std::forward<decltype(schedule_simd)>(schedule_simd));
|
|
}
|
|
|
|
void WsloopOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/::mlir::UnitAttr nowait, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::IntegerAttr ordered, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::omp::ClauseScheduleKindAttr schedule_kind, /*optional*/::mlir::Value schedule_chunk, /*optional*/::mlir::omp::ScheduleModifierAttr schedule_mod, /*optional*/::mlir::UnitAttr schedule_simd) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(linear_vars);
|
|
odsState.addOperands(linear_step_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
if (schedule_chunk)
|
|
odsState.addOperands(schedule_chunk);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(linear_vars.size()), static_cast<int32_t>(linear_step_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size()), (schedule_chunk ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (linear_var_types) {
|
|
odsState.getOrAddProperties<Properties>().linear_var_types = linear_var_types;
|
|
}
|
|
if (linear_modifiers) {
|
|
odsState.getOrAddProperties<Properties>().linear_modifiers = linear_modifiers;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = nowait;
|
|
}
|
|
if (order) {
|
|
odsState.getOrAddProperties<Properties>().order = order;
|
|
}
|
|
if (order_mod) {
|
|
odsState.getOrAddProperties<Properties>().order_mod = order_mod;
|
|
}
|
|
if (ordered) {
|
|
odsState.getOrAddProperties<Properties>().ordered = ordered;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = private_needs_barrier;
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
if (schedule_kind) {
|
|
odsState.getOrAddProperties<Properties>().schedule_kind = schedule_kind;
|
|
}
|
|
if (schedule_mod) {
|
|
odsState.getOrAddProperties<Properties>().schedule_mod = schedule_mod;
|
|
}
|
|
if (schedule_simd) {
|
|
odsState.getOrAddProperties<Properties>().schedule_simd = schedule_simd;
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
WsloopOp WsloopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/::mlir::UnitAttr nowait, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::IntegerAttr ordered, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::omp::ClauseScheduleKindAttr schedule_kind, /*optional*/::mlir::Value schedule_chunk, /*optional*/::mlir::omp::ScheduleModifierAttr schedule_mod, /*optional*/::mlir::UnitAttr schedule_simd) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(nowait)>(nowait), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(ordered)>(ordered), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(schedule_kind)>(schedule_kind), std::forward<decltype(schedule_chunk)>(schedule_chunk), std::forward<decltype(schedule_mod)>(schedule_mod), std::forward<decltype(schedule_simd)>(schedule_simd));
|
|
auto __res__ = ::llvm::dyn_cast<WsloopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WsloopOp WsloopOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/::mlir::UnitAttr nowait, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::IntegerAttr ordered, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/::mlir::UnitAttr private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::omp::ClauseScheduleKindAttr schedule_kind, /*optional*/::mlir::Value schedule_chunk, /*optional*/::mlir::omp::ScheduleModifierAttr schedule_mod, /*optional*/::mlir::UnitAttr schedule_simd) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(nowait)>(nowait), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(ordered)>(ordered), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(schedule_kind)>(schedule_kind), std::forward<decltype(schedule_chunk)>(schedule_chunk), std::forward<decltype(schedule_mod)>(schedule_mod), std::forward<decltype(schedule_simd)>(schedule_simd));
|
|
}
|
|
|
|
void WsloopOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/bool nowait, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::IntegerAttr ordered, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::omp::ClauseScheduleKindAttr schedule_kind, /*optional*/::mlir::Value schedule_chunk, /*optional*/::mlir::omp::ScheduleModifierAttr schedule_mod, /*optional*/bool schedule_simd) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(linear_vars);
|
|
odsState.addOperands(linear_step_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
if (schedule_chunk)
|
|
odsState.addOperands(schedule_chunk);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(linear_vars.size()), static_cast<int32_t>(linear_step_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size()), (schedule_chunk ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (linear_var_types) {
|
|
odsState.getOrAddProperties<Properties>().linear_var_types = linear_var_types;
|
|
}
|
|
if (linear_modifiers) {
|
|
odsState.getOrAddProperties<Properties>().linear_modifiers = linear_modifiers;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (order) {
|
|
odsState.getOrAddProperties<Properties>().order = order;
|
|
}
|
|
if (order_mod) {
|
|
odsState.getOrAddProperties<Properties>().order_mod = order_mod;
|
|
}
|
|
if (ordered) {
|
|
odsState.getOrAddProperties<Properties>().ordered = ordered;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
if (schedule_kind) {
|
|
odsState.getOrAddProperties<Properties>().schedule_kind = schedule_kind;
|
|
}
|
|
if (schedule_mod) {
|
|
odsState.getOrAddProperties<Properties>().schedule_mod = schedule_mod;
|
|
}
|
|
if (schedule_simd) {
|
|
odsState.getOrAddProperties<Properties>().schedule_simd = ((schedule_simd) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
(void)odsState.addRegion();
|
|
}
|
|
|
|
WsloopOp WsloopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/bool nowait, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::IntegerAttr ordered, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::omp::ClauseScheduleKindAttr schedule_kind, /*optional*/::mlir::Value schedule_chunk, /*optional*/::mlir::omp::ScheduleModifierAttr schedule_mod, /*optional*/bool schedule_simd) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(nowait)>(nowait), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(ordered)>(ordered), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(schedule_kind)>(schedule_kind), std::forward<decltype(schedule_chunk)>(schedule_chunk), std::forward<decltype(schedule_mod)>(schedule_mod), std::forward<decltype(schedule_simd)>(schedule_simd));
|
|
auto __res__ = ::llvm::dyn_cast<WsloopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WsloopOp WsloopOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/bool nowait, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::IntegerAttr ordered, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::omp::ClauseScheduleKindAttr schedule_kind, /*optional*/::mlir::Value schedule_chunk, /*optional*/::mlir::omp::ScheduleModifierAttr schedule_mod, /*optional*/bool schedule_simd) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(nowait)>(nowait), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(ordered)>(ordered), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(schedule_kind)>(schedule_kind), std::forward<decltype(schedule_chunk)>(schedule_chunk), std::forward<decltype(schedule_mod)>(schedule_mod), std::forward<decltype(schedule_simd)>(schedule_simd));
|
|
}
|
|
|
|
void WsloopOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/bool nowait, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::IntegerAttr ordered, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::omp::ClauseScheduleKindAttr schedule_kind, /*optional*/::mlir::Value schedule_chunk, /*optional*/::mlir::omp::ScheduleModifierAttr schedule_mod, /*optional*/bool schedule_simd) {
|
|
odsState.addOperands(allocate_vars);
|
|
odsState.addOperands(allocator_vars);
|
|
odsState.addOperands(linear_vars);
|
|
odsState.addOperands(linear_step_vars);
|
|
odsState.addOperands(private_vars);
|
|
odsState.addOperands(reduction_vars);
|
|
if (schedule_chunk)
|
|
odsState.addOperands(schedule_chunk);
|
|
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(allocate_vars.size()), static_cast<int32_t>(allocator_vars.size()), static_cast<int32_t>(linear_vars.size()), static_cast<int32_t>(linear_step_vars.size()), static_cast<int32_t>(private_vars.size()), static_cast<int32_t>(reduction_vars.size()), (schedule_chunk ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
|
|
if (linear_var_types) {
|
|
odsState.getOrAddProperties<Properties>().linear_var_types = linear_var_types;
|
|
}
|
|
if (linear_modifiers) {
|
|
odsState.getOrAddProperties<Properties>().linear_modifiers = linear_modifiers;
|
|
}
|
|
if (nowait) {
|
|
odsState.getOrAddProperties<Properties>().nowait = ((nowait) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (order) {
|
|
odsState.getOrAddProperties<Properties>().order = order;
|
|
}
|
|
if (order_mod) {
|
|
odsState.getOrAddProperties<Properties>().order_mod = order_mod;
|
|
}
|
|
if (ordered) {
|
|
odsState.getOrAddProperties<Properties>().ordered = ordered;
|
|
}
|
|
if (private_syms) {
|
|
odsState.getOrAddProperties<Properties>().private_syms = private_syms;
|
|
}
|
|
if (private_needs_barrier) {
|
|
odsState.getOrAddProperties<Properties>().private_needs_barrier = ((private_needs_barrier) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
if (reduction_mod) {
|
|
odsState.getOrAddProperties<Properties>().reduction_mod = reduction_mod;
|
|
}
|
|
if (reduction_byref) {
|
|
odsState.getOrAddProperties<Properties>().reduction_byref = reduction_byref;
|
|
}
|
|
if (reduction_syms) {
|
|
odsState.getOrAddProperties<Properties>().reduction_syms = reduction_syms;
|
|
}
|
|
if (schedule_kind) {
|
|
odsState.getOrAddProperties<Properties>().schedule_kind = schedule_kind;
|
|
}
|
|
if (schedule_mod) {
|
|
odsState.getOrAddProperties<Properties>().schedule_mod = schedule_mod;
|
|
}
|
|
if (schedule_simd) {
|
|
odsState.getOrAddProperties<Properties>().schedule_simd = ((schedule_simd) ? odsBuilder.getUnitAttr() : nullptr);
|
|
}
|
|
(void)odsState.addRegion();
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
WsloopOp WsloopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/bool nowait, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::IntegerAttr ordered, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::omp::ClauseScheduleKindAttr schedule_kind, /*optional*/::mlir::Value schedule_chunk, /*optional*/::mlir::omp::ScheduleModifierAttr schedule_mod, /*optional*/bool schedule_simd) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(nowait)>(nowait), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(ordered)>(ordered), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(schedule_kind)>(schedule_kind), std::forward<decltype(schedule_chunk)>(schedule_chunk), std::forward<decltype(schedule_mod)>(schedule_mod), std::forward<decltype(schedule_simd)>(schedule_simd));
|
|
auto __res__ = ::llvm::dyn_cast<WsloopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WsloopOp WsloopOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange allocate_vars, ::mlir::ValueRange allocator_vars, ::mlir::ValueRange linear_vars, ::mlir::ValueRange linear_step_vars, /*optional*/::mlir::ArrayAttr linear_var_types, /*optional*/::mlir::ArrayAttr linear_modifiers, /*optional*/bool nowait, /*optional*/::mlir::omp::ClauseOrderKindAttr order, /*optional*/::mlir::omp::OrderModifierAttr order_mod, /*optional*/::mlir::IntegerAttr ordered, ::mlir::ValueRange private_vars, /*optional*/::mlir::ArrayAttr private_syms, /*optional*/bool private_needs_barrier, /*optional*/::mlir::omp::ReductionModifierAttr reduction_mod, ::mlir::ValueRange reduction_vars, /*optional*/::mlir::DenseBoolArrayAttr reduction_byref, /*optional*/::mlir::ArrayAttr reduction_syms, /*optional*/::mlir::omp::ClauseScheduleKindAttr schedule_kind, /*optional*/::mlir::Value schedule_chunk, /*optional*/::mlir::omp::ScheduleModifierAttr schedule_mod, /*optional*/bool schedule_simd) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(allocate_vars)>(allocate_vars), std::forward<decltype(allocator_vars)>(allocator_vars), std::forward<decltype(linear_vars)>(linear_vars), std::forward<decltype(linear_step_vars)>(linear_step_vars), std::forward<decltype(linear_var_types)>(linear_var_types), std::forward<decltype(linear_modifiers)>(linear_modifiers), std::forward<decltype(nowait)>(nowait), std::forward<decltype(order)>(order), std::forward<decltype(order_mod)>(order_mod), std::forward<decltype(ordered)>(ordered), std::forward<decltype(private_vars)>(private_vars), std::forward<decltype(private_syms)>(private_syms), std::forward<decltype(private_needs_barrier)>(private_needs_barrier), std::forward<decltype(reduction_mod)>(reduction_mod), std::forward<decltype(reduction_vars)>(reduction_vars), std::forward<decltype(reduction_byref)>(reduction_byref), std::forward<decltype(reduction_syms)>(reduction_syms), std::forward<decltype(schedule_kind)>(schedule_kind), std::forward<decltype(schedule_chunk)>(schedule_chunk), std::forward<decltype(schedule_mod)>(schedule_mod), std::forward<decltype(schedule_simd)>(schedule_simd));
|
|
}
|
|
|
|
void WsloopOp::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<WsloopOp::Properties>();
|
|
::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.");
|
|
}
|
|
}
|
|
|
|
WsloopOp WsloopOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<WsloopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WsloopOp WsloopOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
}
|
|
|
|
void WsloopOp::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&>(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);
|
|
}
|
|
|
|
WsloopOp WsloopOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<WsloopOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WsloopOp WsloopOp::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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
}
|
|
|
|
::llvm::LogicalResult WsloopOp::verifyInvariantsImpl() {
|
|
auto tblgen_linear_modifiers = getProperties().linear_modifiers; (void)tblgen_linear_modifiers;
|
|
auto tblgen_linear_var_types = getProperties().linear_var_types; (void)tblgen_linear_var_types;
|
|
auto tblgen_nowait = getProperties().nowait; (void)tblgen_nowait;
|
|
auto tblgen_order = getProperties().order; (void)tblgen_order;
|
|
auto tblgen_order_mod = getProperties().order_mod; (void)tblgen_order_mod;
|
|
auto tblgen_ordered = getProperties().ordered; (void)tblgen_ordered;
|
|
auto tblgen_private_needs_barrier = getProperties().private_needs_barrier; (void)tblgen_private_needs_barrier;
|
|
auto tblgen_private_syms = getProperties().private_syms; (void)tblgen_private_syms;
|
|
auto tblgen_reduction_byref = getProperties().reduction_byref; (void)tblgen_reduction_byref;
|
|
auto tblgen_reduction_mod = getProperties().reduction_mod; (void)tblgen_reduction_mod;
|
|
auto tblgen_reduction_syms = getProperties().reduction_syms; (void)tblgen_reduction_syms;
|
|
auto tblgen_schedule_kind = getProperties().schedule_kind; (void)tblgen_schedule_kind;
|
|
auto tblgen_schedule_mod = getProperties().schedule_mod; (void)tblgen_schedule_mod;
|
|
auto tblgen_schedule_simd = getProperties().schedule_simd; (void)tblgen_schedule_simd;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps11(*this, tblgen_linear_var_types, "linear_var_types")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps11(*this, tblgen_linear_modifiers, "linear_modifiers")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_nowait, "nowait")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps12(*this, tblgen_order, "order")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps13(*this, tblgen_order_mod, "order_mod")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps26(*this, tblgen_ordered, "ordered")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_private_syms, "private_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_private_needs_barrier, "private_needs_barrier")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps19(*this, tblgen_reduction_mod, "reduction_mod")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps20(*this, tblgen_reduction_byref, "reduction_byref")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps14(*this, tblgen_reduction_syms, "reduction_syms")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps35(*this, tblgen_schedule_kind, "schedule_kind")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps36(*this, tblgen_schedule_mod, "schedule_mod")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenMPOps5(*this, tblgen_schedule_simd, "schedule_simd")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps12(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup4 = getODSOperands(4);
|
|
|
|
for (auto v : valueGroup4) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup5 = getODSOperands(5);
|
|
|
|
for (auto v : valueGroup5) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_OpenMPOps10(*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_OpenMPOps7(*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_OpenMPOps2(*this, region, "region", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult WsloopOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult WsloopOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocate_varsOperands;
|
|
::llvm::SMLoc allocate_varsOperandsLoc;
|
|
(void)allocate_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocate_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allocator_varsOperands;
|
|
::llvm::SMLoc allocator_varsOperandsLoc;
|
|
(void)allocator_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> allocator_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> linear_varsOperands;
|
|
::llvm::SMLoc linear_varsOperandsLoc;
|
|
(void)linear_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> linear_varsTypes;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> linear_step_varsOperands;
|
|
::llvm::SMLoc linear_step_varsOperandsLoc;
|
|
(void)linear_step_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> linear_step_varsTypes;
|
|
::mlir::ArrayAttr linear_modifiersAttr;
|
|
::mlir::omp::ClauseOrderKindAttr orderAttr;
|
|
::mlir::omp::OrderModifierAttr order_modAttr;
|
|
::mlir::IntegerAttr orderedAttr;
|
|
::mlir::omp::ClauseScheduleKindAttr schedule_kindAttr;
|
|
::mlir::omp::ScheduleModifierAttr schedule_modAttr;
|
|
::mlir::UnitAttr schedule_simdAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> schedule_chunkOperands;
|
|
::llvm::SMLoc schedule_chunkOperandsLoc;
|
|
(void)schedule_chunkOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> schedule_chunkTypes;
|
|
std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>();
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> private_varsOperands;
|
|
::llvm::SMLoc private_varsOperandsLoc;
|
|
(void)private_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> private_varsTypes;
|
|
::mlir::ArrayAttr private_symsAttr;
|
|
::mlir::UnitAttr private_needs_barrierAttr;
|
|
::mlir::omp::ReductionModifierAttr reduction_modAttr;
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> reduction_varsOperands;
|
|
::llvm::SMLoc reduction_varsOperandsLoc;
|
|
(void)reduction_varsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> reduction_varsTypes;
|
|
::mlir::DenseBoolArrayAttr reduction_byrefAttr;
|
|
::mlir::ArrayAttr reduction_symsAttr;
|
|
bool allocateClause = false;
|
|
bool linearClause = false;
|
|
bool nowaitClause = false;
|
|
bool orderClause = false;
|
|
bool orderedClause = false;
|
|
bool scheduleClause = false;
|
|
while(true) {
|
|
if (succeeded(parser.parseOptionalKeyword("allocate"))) {
|
|
|
|
if (allocateClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`allocate` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
allocateClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
allocate_varsOperandsLoc = parser.getCurrentLocation();
|
|
allocator_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseAllocateAndAllocator(parser, allocate_varsOperands, allocate_varsTypes, allocator_varsOperands, allocator_varsTypes);
|
|
if (odsResult) return ::mlir::failure();
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("linear"))) {
|
|
|
|
if (linearClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`linear` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
linearClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
linear_varsOperandsLoc = parser.getCurrentLocation();
|
|
linear_step_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parseLinearClause(parser, linear_varsOperands, linear_varsTypes, linear_step_varsOperands, linear_step_varsTypes, linear_modifiersAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (linear_modifiersAttr)
|
|
result.getOrAddProperties<WsloopOp::Properties>().linear_modifiers = linear_modifiersAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("nowait"))) {
|
|
|
|
if (nowaitClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`nowait` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
nowaitClause = true;
|
|
result.getOrAddProperties<WsloopOp::Properties>().nowait = parser.getBuilder().getUnitAttr(); } else if (succeeded(parser.parseOptionalKeyword("order"))) {
|
|
|
|
if (orderClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`order` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
orderClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
auto odsResult = parseOrderClause(parser, orderAttr, order_modAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (orderAttr)
|
|
result.getOrAddProperties<WsloopOp::Properties>().order = orderAttr;
|
|
if (order_modAttr)
|
|
result.getOrAddProperties<WsloopOp::Properties>().order_mod = order_modAttr;
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("ordered"))) {
|
|
|
|
if (orderedClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`ordered` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
orderedClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
|
|
::mlir::OptionalParseResult parseResultorderedAttr =
|
|
parser.parseOptionalAttribute(orderedAttr, parser.getBuilder().getIntegerType(64));
|
|
if (parseResultorderedAttr.has_value() && failed(*parseResultorderedAttr))
|
|
return ::mlir::failure();
|
|
if (parseResultorderedAttr.has_value() && succeeded(*parseResultorderedAttr))
|
|
if (orderedAttr) result.getOrAddProperties<WsloopOp::Properties>().ordered = orderedAttr;
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else if (succeeded(parser.parseOptionalKeyword("schedule"))) {
|
|
|
|
if (scheduleClause) {
|
|
return parser.emitError(parser.getNameLoc())
|
|
<< "`schedule` clause can appear at most once in the expansion of the "
|
|
"oilist directive";
|
|
}
|
|
scheduleClause = true;
|
|
if (parser.parseLParen())
|
|
return ::mlir::failure();
|
|
{
|
|
schedule_chunkOperandsLoc = parser.getCurrentLocation();
|
|
::std::optional<::mlir::OpAsmParser::UnresolvedOperand> schedule_chunkOperand;
|
|
::mlir::Type schedule_chunkType;
|
|
auto odsResult = parseScheduleClause(parser, schedule_kindAttr, schedule_modAttr, schedule_simdAttr, schedule_chunkOperand, schedule_chunkType);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (schedule_kindAttr)
|
|
result.getOrAddProperties<WsloopOp::Properties>().schedule_kind = schedule_kindAttr;
|
|
if (schedule_modAttr)
|
|
result.getOrAddProperties<WsloopOp::Properties>().schedule_mod = schedule_modAttr;
|
|
if (schedule_simdAttr)
|
|
result.getOrAddProperties<WsloopOp::Properties>().schedule_simd = schedule_simdAttr;
|
|
if (schedule_chunkOperand.has_value())
|
|
schedule_chunkOperands.push_back(*schedule_chunkOperand);
|
|
if (schedule_chunkType)
|
|
schedule_chunkTypes.push_back(schedule_chunkType);
|
|
}
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
{
|
|
private_varsOperandsLoc = parser.getCurrentLocation();
|
|
reduction_varsOperandsLoc = parser.getCurrentLocation();
|
|
auto odsResult = parsePrivateReductionRegion(parser, *regionRegion, private_varsOperands, private_varsTypes, private_symsAttr, private_needs_barrierAttr, reduction_modAttr, reduction_varsOperands, reduction_varsTypes, reduction_byrefAttr, reduction_symsAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
if (private_symsAttr)
|
|
result.getOrAddProperties<WsloopOp::Properties>().private_syms = private_symsAttr;
|
|
if (private_needs_barrierAttr)
|
|
result.getOrAddProperties<WsloopOp::Properties>().private_needs_barrier = private_needs_barrierAttr;
|
|
if (reduction_modAttr)
|
|
result.getOrAddProperties<WsloopOp::Properties>().reduction_mod = reduction_modAttr;
|
|
if (reduction_byrefAttr)
|
|
result.getOrAddProperties<WsloopOp::Properties>().reduction_byref = reduction_byrefAttr;
|
|
if (reduction_symsAttr)
|
|
result.getOrAddProperties<WsloopOp::Properties>().reduction_syms = reduction_symsAttr;
|
|
}
|
|
{
|
|
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<int32_t>({static_cast<int32_t>(allocate_varsOperands.size()), static_cast<int32_t>(allocator_varsOperands.size()), static_cast<int32_t>(linear_varsOperands.size()), static_cast<int32_t>(linear_step_varsOperands.size()), static_cast<int32_t>(private_varsOperands.size()), static_cast<int32_t>(reduction_varsOperands.size()), static_cast<int32_t>(schedule_chunkOperands.size())}), result.getOrAddProperties<WsloopOp::Properties>().operandSegmentSizes.begin());
|
|
if (parser.resolveOperands(allocate_varsOperands, allocate_varsTypes, allocate_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(allocator_varsOperands, allocator_varsTypes, allocator_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(linear_varsOperands, linear_varsTypes, linear_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(linear_step_varsOperands, linear_step_varsTypes, linear_step_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(private_varsOperands, private_varsTypes, private_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(reduction_varsOperands, reduction_varsTypes, reduction_varsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
if (!schedule_chunkOperands.empty()) {
|
|
if (parser.resolveOperands(schedule_chunkOperands, schedule_chunkTypes, schedule_chunkOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void WsloopOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (false || getAllocateVars().size() || getAllocatorVars().size()) {
|
|
_odsPrinter << ' ' << "allocate";
|
|
_odsPrinter << "(";
|
|
printAllocateAndAllocator(_odsPrinter, *this, getAllocateVars(), getAllocateVars().getTypes(), getAllocatorVars(), getAllocatorVars().getTypes());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || getLinearVars().size() || getLinearStepVars().size() || (getLinearModifiersAttr())) {
|
|
_odsPrinter << ' ' << "linear";
|
|
_odsPrinter << "(";
|
|
printLinearClause(_odsPrinter, *this, getLinearVars(), getLinearVars().getTypes(), getLinearStepVars(), getLinearStepVars().getTypes(), getLinearModifiersAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || ((getNowaitAttr() && getNowaitAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) {
|
|
_odsPrinter << ' ' << "nowait";
|
|
}
|
|
if (false || (getOrderAttr()) || (getOrderModAttr())) {
|
|
_odsPrinter << ' ' << "order";
|
|
_odsPrinter << "(";
|
|
printOrderClause(_odsPrinter, *this, getOrderAttr(), getOrderModAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getOrderedAttr())) {
|
|
_odsPrinter << ' ' << "ordered";
|
|
_odsPrinter << "(";
|
|
_odsPrinter.printAttributeWithoutType(getOrderedAttr());
|
|
_odsPrinter << ")";
|
|
}
|
|
if (false || (getScheduleKindAttr()) || (getScheduleModAttr()) || ((getScheduleSimdAttr() && getScheduleSimdAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) || getScheduleChunk()) {
|
|
_odsPrinter << ' ' << "schedule";
|
|
_odsPrinter << "(";
|
|
printScheduleClause(_odsPrinter, *this, getScheduleKindAttr(), getScheduleModAttr(), getScheduleSimdAttr(), getScheduleChunk(), (getScheduleChunk() ? getScheduleChunk().getType() : ::mlir::Type()));
|
|
_odsPrinter << ")";
|
|
}
|
|
_odsPrinter << ' ';
|
|
printPrivateReductionRegion(_odsPrinter, *this, getRegion(), getPrivateVars(), getPrivateVars().getTypes(), getPrivateSymsAttr(), getPrivateNeedsBarrierAttr(), getReductionModAttr(), getReductionVars(), getReductionVars().getTypes(), getReductionByrefAttr(), getReductionSymsAttr());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("operandSegmentSizes");
|
|
elidedAttrs.push_back("linear_modifiers");
|
|
elidedAttrs.push_back("nowait");
|
|
elidedAttrs.push_back("order");
|
|
elidedAttrs.push_back("order_mod");
|
|
elidedAttrs.push_back("ordered");
|
|
elidedAttrs.push_back("schedule_kind");
|
|
elidedAttrs.push_back("schedule_mod");
|
|
elidedAttrs.push_back("schedule_simd");
|
|
elidedAttrs.push_back("private_syms");
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
elidedAttrs.push_back("reduction_mod");
|
|
elidedAttrs.push_back("reduction_byref");
|
|
elidedAttrs.push_back("reduction_syms");
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getNowaitAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("nowait");
|
|
}
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getPrivateNeedsBarrierAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("private_needs_barrier");
|
|
}
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getScheduleSimdAttr();
|
|
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
|
|
elidedAttrs.push_back("schedule_simd");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::WsloopOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::detail::WsloopOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::omp {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// ::mlir::omp::YieldOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
YieldOpGenericAdaptorBase::YieldOpGenericAdaptorBase(YieldOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> 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<unsigned, unsigned> 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::getResultsMutable() {
|
|
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<mlir::Attribute> 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) {
|
|
build(odsBuilder, odsState, {});
|
|
}
|
|
|
|
YieldOp YieldOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__);
|
|
auto __res__ = ::llvm::dyn_cast<YieldOp>(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 results) {
|
|
odsState.addOperands(results);
|
|
}
|
|
|
|
YieldOp YieldOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange results) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(results)>(results));
|
|
auto __res__ = ::llvm::dyn_cast<YieldOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
YieldOp YieldOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange results) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(results)>(results));
|
|
}
|
|
|
|
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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
|
|
auto __res__ = ::llvm::dyn_cast<YieldOp>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(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&>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
|
|
auto __res__ = ::llvm::dyn_cast<YieldOp>(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<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(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_OpenMPOps5(*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> resultsOperands;
|
|
::llvm::SMLoc resultsOperandsLoc;
|
|
(void)resultsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> resultsTypes;
|
|
if (::mlir::succeeded(parser.parseOptionalLParen())) {
|
|
|
|
resultsOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(resultsOperands))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(resultsTypes))
|
|
return ::mlir::failure();
|
|
if (parser.parseRParen())
|
|
return ::mlir::failure();
|
|
}
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
|
|
return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
|
|
})))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.resolveOperands(resultsOperands, resultsTypes, resultsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void YieldOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
if (!getResults().empty()) {
|
|
_odsPrinter << "(";
|
|
_odsPrinter << getResults();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getResults().getTypes();
|
|
_odsPrinter << ")";
|
|
}
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
}
|
|
|
|
void YieldOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::omp
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::omp::YieldOp)
|
|
|
|
|
|
#endif // GET_OP_CLASSES
|
|
|