/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |* *| |* Op Definitions *| |* *| |* Automatically generated file, do not edit! *| |* From: NVVMOps.td *| |* *| \*===----------------------------------------------------------------------===*/ #ifdef GET_OP_LIST #undef GET_OP_LIST ::mlir::NVVM::AddFOp, ::mlir::NVVM::AggrSmemSize, ::mlir::NVVM::BarrierArriveOp, ::mlir::NVVM::BarrierOp, ::mlir::NVVM::BarrierReductionOp, ::mlir::NVVM::BlockDimXOp, ::mlir::NVVM::BlockDimYOp, ::mlir::NVVM::BlockDimZOp, ::mlir::NVVM::BlockIdXOp, ::mlir::NVVM::BlockIdYOp, ::mlir::NVVM::BlockIdZOp, ::mlir::NVVM::BlockInClusterIdXOp, ::mlir::NVVM::BlockInClusterIdYOp, ::mlir::NVVM::BlockInClusterIdZOp, ::mlir::NVVM::Breakpoint, ::mlir::NVVM::BulkStoreOp, ::mlir::NVVM::Clock64Op, ::mlir::NVVM::ClockOp, ::mlir::NVVM::ClusterArriveOp, ::mlir::NVVM::ClusterArriveRelaxedOp, ::mlir::NVVM::ClusterDim, ::mlir::NVVM::ClusterDimBlocksXOp, ::mlir::NVVM::ClusterDimBlocksYOp, ::mlir::NVVM::ClusterDimBlocksZOp, ::mlir::NVVM::ClusterDimXOp, ::mlir::NVVM::ClusterDimYOp, ::mlir::NVVM::ClusterDimZOp, ::mlir::NVVM::ClusterId, ::mlir::NVVM::ClusterIdXOp, ::mlir::NVVM::ClusterIdYOp, ::mlir::NVVM::ClusterIdZOp, ::mlir::NVVM::ClusterLaunchControlQueryCancelOp, ::mlir::NVVM::ClusterLaunchControlTryCancelOp, ::mlir::NVVM::ClusterWaitOp, ::mlir::NVVM::ConvertBF16x2ToF4x2Op, ::mlir::NVVM::ConvertBF16x2ToF6x2Op, ::mlir::NVVM::ConvertBF16x2ToF8x2Op, ::mlir::NVVM::ConvertBF16x2ToS2F6x2Op, ::mlir::NVVM::ConvertF16x2ToF4x2Op, ::mlir::NVVM::ConvertF16x2ToF6x2Op, ::mlir::NVVM::ConvertF16x2ToF8x2Op, ::mlir::NVVM::ConvertF32x2ToBF16x2Op, ::mlir::NVVM::ConvertF32x2ToF16x2Op, ::mlir::NVVM::ConvertF32x2ToF4x2Op, ::mlir::NVVM::ConvertF32x2ToF6x2Op, ::mlir::NVVM::ConvertF32x2ToF8x2Op, ::mlir::NVVM::ConvertF32x2ToS2F6x2Op, ::mlir::NVVM::ConvertF32x4ToF4x4Op, ::mlir::NVVM::ConvertF32x4ToF6x4Op, ::mlir::NVVM::ConvertF32x4ToF8x4Op, ::mlir::NVVM::ConvertF4x2ToBF16x2Op, ::mlir::NVVM::ConvertF4x2ToF16x2Op, ::mlir::NVVM::ConvertF6x2ToBF16x2Op, ::mlir::NVVM::ConvertF6x2ToF16x2Op, ::mlir::NVVM::ConvertF8x2ToBF16x2Op, ::mlir::NVVM::ConvertF8x2ToF16x2Op, ::mlir::NVVM::ConvertFloatToTF32Op, ::mlir::NVVM::ConvertS2F6x2ToBF16x2Op, ::mlir::NVVM::CosOp, ::mlir::NVVM::CpAsyncBulkCommitGroupOp, ::mlir::NVVM::CpAsyncBulkGlobalToSharedClusterOp, ::mlir::NVVM::CpAsyncBulkPrefetchOp, ::mlir::NVVM::CpAsyncBulkSharedCTAToGlobalOp, ::mlir::NVVM::CpAsyncBulkSharedCTAToSharedClusterOp, ::mlir::NVVM::CpAsyncBulkTensorGlobalToSharedClusterOp, ::mlir::NVVM::CpAsyncBulkTensorPrefetchOp, ::mlir::NVVM::CpAsyncBulkTensorReduceOp, ::mlir::NVVM::CpAsyncBulkTensorSharedCTAToGlobalOp, ::mlir::NVVM::CpAsyncBulkWaitGroupOp, ::mlir::NVVM::CpAsyncCommitGroupOp, ::mlir::NVVM::CpAsyncMBarrierArriveOp, ::mlir::NVVM::CpAsyncOp, ::mlir::NVVM::CpAsyncWaitGroupOp, ::mlir::NVVM::DivFOp, ::mlir::NVVM::DotAccumulate2WayOp, ::mlir::NVVM::DotAccumulate4WayOp, ::mlir::NVVM::DynamicSmemSize, ::mlir::NVVM::ElectSyncOp, ::mlir::NVVM::EnvReg0Op, ::mlir::NVVM::EnvReg10Op, ::mlir::NVVM::EnvReg11Op, ::mlir::NVVM::EnvReg12Op, ::mlir::NVVM::EnvReg13Op, ::mlir::NVVM::EnvReg14Op, ::mlir::NVVM::EnvReg15Op, ::mlir::NVVM::EnvReg16Op, ::mlir::NVVM::EnvReg17Op, ::mlir::NVVM::EnvReg18Op, ::mlir::NVVM::EnvReg19Op, ::mlir::NVVM::EnvReg1Op, ::mlir::NVVM::EnvReg20Op, ::mlir::NVVM::EnvReg21Op, ::mlir::NVVM::EnvReg22Op, ::mlir::NVVM::EnvReg23Op, ::mlir::NVVM::EnvReg24Op, ::mlir::NVVM::EnvReg25Op, ::mlir::NVVM::EnvReg26Op, ::mlir::NVVM::EnvReg27Op, ::mlir::NVVM::EnvReg28Op, ::mlir::NVVM::EnvReg29Op, ::mlir::NVVM::EnvReg2Op, ::mlir::NVVM::EnvReg30Op, ::mlir::NVVM::EnvReg31Op, ::mlir::NVVM::EnvReg3Op, ::mlir::NVVM::EnvReg4Op, ::mlir::NVVM::EnvReg5Op, ::mlir::NVVM::EnvReg6Op, ::mlir::NVVM::EnvReg7Op, ::mlir::NVVM::EnvReg8Op, ::mlir::NVVM::EnvReg9Op, ::mlir::NVVM::Ex2Op, ::mlir::NVVM::Exit, ::mlir::NVVM::FenceMbarrierInitOp, ::mlir::NVVM::FenceProxyAcquireOp, ::mlir::NVVM::FenceProxyOp, ::mlir::NVVM::FenceProxyReleaseOp, ::mlir::NVVM::FenceProxySyncRestrictOp, ::mlir::NVVM::FenceScClusterOp, ::mlir::NVVM::FenceSyncRestrictOp, ::mlir::NVVM::FmaOp, ::mlir::NVVM::GlobalTimerLoOp, ::mlir::NVVM::GlobalTimerOp, ::mlir::NVVM::GridDimXOp, ::mlir::NVVM::GridDimYOp, ::mlir::NVVM::GridDimZOp, ::mlir::NVVM::GridIdOp, ::mlir::NVVM::GriddepcontrolOp, ::mlir::NVVM::InlinePtxOp, ::mlir::NVVM::LaneIdOp, ::mlir::NVVM::LaneMaskEqOp, ::mlir::NVVM::LaneMaskGeOp, ::mlir::NVVM::LaneMaskGtOp, ::mlir::NVVM::LaneMaskLeOp, ::mlir::NVVM::LaneMaskLtOp, ::mlir::NVVM::LdMatrixOp, ::mlir::NVVM::Log2Op, ::mlir::NVVM::MBarrierArriveDropExpectTxOp, ::mlir::NVVM::MBarrierArriveDropNocompleteOp, ::mlir::NVVM::MBarrierArriveDropOp, ::mlir::NVVM::MBarrierArriveExpectTxOp, ::mlir::NVVM::MBarrierArriveNocompleteOp, ::mlir::NVVM::MBarrierArriveOp, ::mlir::NVVM::MBarrierCompleteTxOp, ::mlir::NVVM::MBarrierExpectTxOp, ::mlir::NVVM::MBarrierInitOp, ::mlir::NVVM::MBarrierInvalOp, ::mlir::NVVM::MBarrierTestWaitOp, ::mlir::NVVM::MBarrierTryWaitOp, ::mlir::NVVM::MBarrierTryWaitParityOp, ::mlir::NVVM::MapaOp, ::mlir::NVVM::MatchSyncOp, ::mlir::NVVM::MembarOp, ::mlir::NVVM::MmaBlockScaleOp, ::mlir::NVVM::MmaOp, ::mlir::NVVM::MmaSpBlockScaleOp, ::mlir::NVVM::MmaSpOp, ::mlir::NVVM::MovMatrixOp, ::mlir::NVVM::NanosleepOp, ::mlir::NVVM::PMEventOp, ::mlir::NVVM::PermuteOp, ::mlir::NVVM::PrefetchOp, ::mlir::NVVM::RcpApproxFtzF32Op, ::mlir::NVVM::ReduxOp, ::mlir::NVVM::RsqrtOp, ::mlir::NVVM::SetMaxRegisterOp, ::mlir::NVVM::ShflOp, ::mlir::NVVM::SinOp, ::mlir::NVVM::SmDimOp, ::mlir::NVVM::SmIdOp, ::mlir::NVVM::SqrtApproxOp, ::mlir::NVVM::SqrtOp, ::mlir::NVVM::StMatrixOp, ::mlir::NVVM::SubFOp, ::mlir::NVVM::SyncWarpOp, ::mlir::NVVM::Tcgen05AllocOp, ::mlir::NVVM::Tcgen05CommitOp, ::mlir::NVVM::Tcgen05CpOp, ::mlir::NVVM::Tcgen05DeallocOp, ::mlir::NVVM::Tcgen05FenceOp, ::mlir::NVVM::Tcgen05LdOp, ::mlir::NVVM::Tcgen05LdRedOp, ::mlir::NVVM::Tcgen05MMABlockScaleOp, ::mlir::NVVM::Tcgen05MMAOp, ::mlir::NVVM::Tcgen05MMASparseBlockScaleOp, ::mlir::NVVM::Tcgen05MMASparseOp, ::mlir::NVVM::Tcgen05MMAWsOp, ::mlir::NVVM::Tcgen05MMAWsSparseOp, ::mlir::NVVM::Tcgen05MmaSmemDescOp, ::mlir::NVVM::Tcgen05RelinquishAllocPermitOp, ::mlir::NVVM::Tcgen05ShiftOp, ::mlir::NVVM::Tcgen05StOp, ::mlir::NVVM::Tcgen05WaitOp, ::mlir::NVVM::TensormapReplaceOp, ::mlir::NVVM::ThreadIdXOp, ::mlir::NVVM::ThreadIdYOp, ::mlir::NVVM::ThreadIdZOp, ::mlir::NVVM::TotalSmemSize, ::mlir::NVVM::VoteSyncOp, ::mlir::NVVM::WMMALoadOp, ::mlir::NVVM::WMMAMmaOp, ::mlir::NVVM::WMMAStoreOp, ::mlir::NVVM::WarpDimOp, ::mlir::NVVM::WarpIdOp, ::mlir::NVVM::WarpSizeOp, ::mlir::NVVM::WgmmaFenceAlignedOp, ::mlir::NVVM::WgmmaGroupSyncAlignedOp, ::mlir::NVVM::WgmmaMmaAsyncOp, ::mlir::NVVM::WgmmaWaitGroupSyncOp #endif // GET_OP_LIST #ifdef GET_OP_CLASSES #undef GET_OP_CLASSES //===----------------------------------------------------------------------===// // Local Utility Method Definitions //===----------------------------------------------------------------------===// static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps1( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((type.isF16())) || ((::llvm::isa<::mlir::BFloat16Type>(type))) || ((type.isF32())) || ((type.isF64())) || (((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return ((elementType.isF16())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType))) || ((elementType.isF32())) || ((elementType.isF64())); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 2)))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 16-bit float or bfloat16 type or 32-bit float or 64-bit float or vector of 16-bit float or bfloat16 type or 32-bit float or 64-bit float values of length 2, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps2( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((type.isSignlessInteger(32)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 32-bit signless integer, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps3( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 0))) || (((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 3))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be LLVM pointer in address space 0 or LLVM pointer in address space 3, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps4( ::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_NVVMOps5( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((type.isSignlessInteger(128)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 128-bit signless integer, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps6( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((type.isSignlessInteger(1))) || ((type.isSignlessInteger(32))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 1-bit signless integer or 32-bit signless integer, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps7( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 3)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be LLVM pointer in address space 3, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps8( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::BFloat16Type>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 2))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be vector of bfloat16 type values of length 2, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps9( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((type.isSignlessInteger(8)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 8-bit signless integer, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps10( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((type.isSignlessInteger(16))) || (((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(8)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 2)))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 16-bit signless integer or vector of 8-bit signless integer values of length 2, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps11( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((type.isSignlessInteger(16)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 16-bit signless integer, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps12( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isF16()); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 2))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be vector of 16-bit float values of length 2, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps13( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((type.isF32()))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 32-bit float, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps14( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isF32()); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 4))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be vector of 32-bit float values of length 4, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps15( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(8)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 4))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be vector of 8-bit signless integer values of length 4, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps16( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(8)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 2))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be vector of 8-bit signless integer values of length 2, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps17( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 3))) || (((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 7))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be LLVM pointer in address space 3 or LLVM pointer in address space 7, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps18( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 1)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be LLVM pointer in address space 1, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps19( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 7)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be LLVM pointer in address space 7, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps20( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 0)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be LLVM pointer in address space 0, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps21( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((type.isSignlessInteger(32)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be variadic of 32-bit signless integer, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps22( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((type.isSignlessInteger(16)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be variadic of 16-bit signless integer, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps23( ::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_NVVMOps24( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be LLVM pointer type, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps25( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((type.isF32())) || ((type.isF64())))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 32-bit float or 64-bit float, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps26( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(16)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 2))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be vector of 16-bit signless integer values of length 2, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps27( ::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_NVVMOps28( ::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_NVVMOps29( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 0))) || (((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 3))) || (((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 7))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be LLVM pointer in address space 0 or LLVM pointer in address space 3 or LLVM pointer in address space 7, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps30( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((type.isSignlessInteger(64))) || ((type.isSignlessInteger(32))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 64-bit signless integer or 32-bit signless integer, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps31( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 0))) || (((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 7))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be LLVM pointer in address space 0 or LLVM pointer in address space 7, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps32( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((type.isSignlessInteger(32))) || ((type.isSignlessInteger(64))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 32-bit signless integer or 64-bit signless integer, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps33( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((type.isSignlessInteger(32))) || ((::llvm::isa<::mlir::LLVM::LLVMStructType>(type))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 32-bit signless integer or LLVM struct type, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps34( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((::mlir::LLVM::isCompatibleOuterType(type)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be variadic of LLVM dialect-compatible type, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps35( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((::llvm::isa<::mlir::LLVM::LLVMStructType>(type)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be LLVM structure type, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps36( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 1))) || (((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 5))) || (((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 0))) || (((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 4))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be LLVM pointer in address space 1 or LLVM pointer in address space 5 or LLVM pointer in address space 0 or LLVM pointer in address space 4, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps37( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((type.isSignlessInteger(32))) || ((type.isF32())))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 32-bit signless integer or 32-bit float, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps38( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((type.isSignlessInteger(32))) || ((type.isF32())) || ((::llvm::isa<::mlir::LLVM::LLVMStructType>(type))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 32-bit signless integer or 32-bit float or LLVM struct type, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps39( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) || (((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 3))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be LLVM pointer type or LLVM pointer in address space 3, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps40( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 6)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be LLVM pointer in address space 6, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps41( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((type.isSignlessInteger(32))) || (((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(32)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && (((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 2)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 4)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 8)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 16)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 32)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 64)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 128))))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 32-bit signless integer or vector of 32-bit signless integer values of length 2/4/8/16/32/64/128, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps42( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger(32))) || ((elementType.isF32())); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && (((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 2)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 4)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 8)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 16)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 32)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 64)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 128)))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be vector of 32-bit signless integer or 32-bit float values of length 2/4/8/16/32/64/128, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps43( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 6))) || ((type.isSignlessInteger(64))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be LLVM pointer in address space 6 or 64-bit signless integer, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps44( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((((::llvm::isa<::mlir::FixedVectorType>(type))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(32)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && (((::llvm::isa<::mlir::FixedVectorType>(type))) && (((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 4)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() == 8)))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be fixed-length vector of 32-bit signless integer values of length 4/8, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps45( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 1))) || (((::llvm::isa<::mlir::LLVM::LLVMPointerType>(type))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>(type).getAddressSpace() == 3))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be LLVM pointer in address space 1 or LLVM pointer in address space 3, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps46( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((type.isSignlessInteger(32))) || ((type.isSignlessInteger(1))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 32-bit signless integer or 1-bit signless integer, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_NVVMOps47( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::LLVM::LLVMStructType>(type))) || ((type.isF64())))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be LLVM structure type or 64-bit float, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps1( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::NVVM::FPRoundingModeAttr>(attr))) && (((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(attr).getValue() == ::mlir::NVVM::FPRoundingMode::NONE)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(attr).getValue() == ::mlir::NVVM::FPRoundingMode::RM)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(attr).getValue() == ::mlir::NVVM::FPRoundingMode::RN)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(attr).getValue() == ::mlir::NVVM::FPRoundingMode::RP)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(attr).getValue() == ::mlir::NVVM::FPRoundingMode::RZ))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM FPRoundingMode kind whose value is one of {none, rm, rn, rp, rz}"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps1( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps1(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps2( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::NVVM::SaturationModeAttr>(attr))) && (((::llvm::cast<::mlir::NVVM::SaturationModeAttr>(attr).getValue() == ::mlir::NVVM::SaturationMode::NONE)) || ((::llvm::cast<::mlir::NVVM::SaturationModeAttr>(attr).getValue() == ::mlir::NVVM::SaturationMode::SAT))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Describes the saturation mode whose value is one of {none, sat}"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps2( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps2(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps3( ::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_NVVMOps3( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps3(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps4( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::BarrierReductionAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM barrier reduction operation"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps4( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps4(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps5( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps5( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps5(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps6( ::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_NVVMOps6( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps6(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps7( ::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_NVVMOps7( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps7(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps8( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::ClusterLaunchControlQueryTypeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM ClusterLaunchControlQueryType"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps8( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps8(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps9( ::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::Float4E2M1FNType>(::llvm::cast<::mlir::TypeAttr>(attr).getValue()))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: type attribute of f4E2M1FN type"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps9( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps9(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps10( ::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::Float6E2M3FNType>(::llvm::cast<::mlir::TypeAttr>(attr).getValue()))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(::llvm::cast<::mlir::TypeAttr>(attr).getValue())))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: type attribute of f6E2M3FN type or f6E3M2FN type"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps10( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps10(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps11( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::FPRoundingModeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM FPRoundingMode kind"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps11( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps11(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps12( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::SaturationModeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Describes the saturation mode"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps12( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps12(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps13( ::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::Float8E8M0FNUType>(::llvm::cast<::mlir::TypeAttr>(attr).getValue()))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(::llvm::cast<::mlir::TypeAttr>(attr).getValue()))) || ((::llvm::isa<::mlir::Float8E5M2Type>(::llvm::cast<::mlir::TypeAttr>(attr).getValue())))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: type attribute of f8E8M0FNU type or f8E4M3FN type or f8E5M2 type"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps13( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps13(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps14( ::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_NVVMOps14( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps14(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps15( ::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::Float4E2M1FNType>(::llvm::cast<::mlir::TypeAttr>(attr).getValue()))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: type attribute of f4E2M1FN type"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps15( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps15(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps16( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::NVVM::SaturationModeAttr>(attr))) && (((::llvm::cast<::mlir::NVVM::SaturationModeAttr>(attr).getValue() == ::mlir::NVVM::SaturationMode::NONE)) || ((::llvm::cast<::mlir::NVVM::SaturationModeAttr>(attr).getValue() == ::mlir::NVVM::SaturationMode::SATFINITE))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Describes the saturation mode whose value is one of {none, satfinite}"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps16( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps16(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps17( ::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::Float8E4M3FNType>(::llvm::cast<::mlir::TypeAttr>(attr).getValue()))) || ((::llvm::isa<::mlir::Float8E5M2Type>(::llvm::cast<::mlir::TypeAttr>(attr).getValue())))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: type attribute of f8E4M3FN type or f8E5M2 type"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps17( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps17(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps18( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::TMALoadModeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: List of Load-Modes supported for TMA Tensor Ops"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps18( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps18(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps19( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::CTAGroupKindAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM CTA group kind"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps19( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps19(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps20( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::TMAReduxKindAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM TMA redux kind"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps20( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps20(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps21( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::TMAStoreModeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM TMA Store Mode"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps21( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps21(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps22( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32)))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() >= 0)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: 32-bit signless integer attribute whose minimum value is 0"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps22( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps22(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps23( ::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(1))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: 1-bit signless integer attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps23( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps23(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps24( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: 32-bit signless integer attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps24( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps24(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps25( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::LoadCacheModifierKindAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM load cache modifier kind"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps25( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps25(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps26( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::DotAccumulateTypeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM DotAccumulateType"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps26( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps26(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps27( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::MemScopeKindAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM Memory Scope kind"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps27( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps27(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps28( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::ProxyKindAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Proxy kind"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps28( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps28(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps29( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::NVVM::ProxyKindAttr>(attr))) && (!(((::llvm::cast<::mlir::NVVM::ProxyKindAttr>(attr).getValue() == ::mlir::NVVM::ProxyKind::TENSORMAP)) || ((::llvm::cast<::mlir::NVVM::ProxyKindAttr>(attr).getValue() == ::mlir::NVVM::ProxyKind::GENERIC)))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Proxy kind whose value is none of {tensormap, generic}"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps29( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps29(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps30( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::SharedSpaceAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Shared memory space"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps30( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps30(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps31( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::NVVM::MemOrderKindAttr>(attr))) && (((::llvm::cast<::mlir::NVVM::MemOrderKindAttr>(attr).getValue() == ::mlir::NVVM::MemOrderKind::ACQUIRE)) || ((::llvm::cast<::mlir::NVVM::MemOrderKindAttr>(attr).getValue() == ::mlir::NVVM::MemOrderKind::RELEASE))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM Memory Ordering kind whose value is one of {acquire, release}"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps31( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps31(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps32( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::GridDepActionKindAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Action kind for grid dependency control"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps32( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps32(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps33( ::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_NVVMOps33( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps33(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps34( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::MMALayoutAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM MMA layout"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps34( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps34(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps35( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::LdStMatrixShapeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Matrix shape for ldmatrix and stmatrix"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps35( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps35(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps36( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::LdStMatrixEltTypeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Element type for ldmatrix and stmatrix"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps36( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps36(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps37( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::MatchSyncKindAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM match sync kind"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps37( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps37(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps38( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::MMAShapeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Attribute for MMA operation shape."; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps38( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps38(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps39( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::MMATypesAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM MMA types"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps39( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps39(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps40( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::ScaleVecSizeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: MMA Scale Vector Sizes"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps40( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps40(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps41( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::BlockScaleFormatAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: MMA Block Scale Format"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps41( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps41(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps42( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::MMABlockScaleKindAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Block Scale Kind"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps42( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps42(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps43( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::MMAB1OpAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: MMA binary operations"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps43( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps43(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps44( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::MMAIntOverflowAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: MMA overflow options"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps44( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps44(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps45( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::MMAKindAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: MMA operation kind"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps45( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps45(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps46( ::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(16))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: 16-bit signless integer attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps46( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps46(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps47( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::PermuteModeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM permute mode"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps47( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps47(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps48( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::PrefetchCacheLevelAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM Prefetch Cache Level"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps48( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps48(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps49( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::CacheEvictionPriorityAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM Cache Eviction Priority"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps49( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps49(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps50( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::ReductionKindAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM Reduction Kind attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps50( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps50(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps51( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::SetMaxRegisterActionAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM set max register action"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps51( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps51(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps52( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::ShflKindAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM shuffle kind"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps52( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps52(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps53( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::Tcgen05CpShapeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: tcgen05 cp shapes"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps53( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps53(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps54( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::Tcgen05CpMulticastAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: tcgen05 cp multicast"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps54( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps54(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps55( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::Tcgen05CpSrcFormatAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: tcgen05 cp source format"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps55( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps55(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps56( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::Tcgen05FenceKindAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM Tcgen05 fence kind"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps56( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps56(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps57( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::Tcgen05LdStShapeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: allowed 32-bit signless integer cases: 0, 1, 2, 3, 4"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps57( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps57(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps58( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::NVVM::Tcgen05MMAKindAttr>(attr))) && (((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(attr).getValue() == ::mlir::NVVM::Tcgen05MMAKind::MXF8F6F4)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(attr).getValue() == ::mlir::NVVM::Tcgen05MMAKind::MXF4)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(attr).getValue() == ::mlir::NVVM::Tcgen05MMAKind::MXF4NVF4))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: tcgen05 MMA Supported Types whose value is one of {mxf8f6f4, mxf4, mxf4nvf4}"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps58( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps58(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps59( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::Tcgen05MMABlockScaleAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: tcgen05.mma block scale attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps59( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps59(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps60( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::Tcgen05MMACollectorOpAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: tcgen05.mma Collector Buffer Operation"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps60( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps60(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps61( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::NVVM::Tcgen05MMAKindAttr>(attr))) && (((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(attr).getValue() == ::mlir::NVVM::Tcgen05MMAKind::F16)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(attr).getValue() == ::mlir::NVVM::Tcgen05MMAKind::TF32)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(attr).getValue() == ::mlir::NVVM::Tcgen05MMAKind::F8F6F4)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(attr).getValue() == ::mlir::NVVM::Tcgen05MMAKind::I8))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: tcgen05 MMA Supported Types whose value is one of {f16, tf32, f8f6f4, i8}"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps61( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps61(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps62( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::Tcgen05MMACollectorBBufferAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: tcgen05 MMA Collector Buffer B Attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps62( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps62(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps63( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::Tcgen05WaitKindAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM Tcgen05 wait kind"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps63( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps63(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps64( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::TensormapFieldAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM Tensormap Field Kind"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps64( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps64(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps65( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32)))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() >= 0)) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() <= 4)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: 32-bit signless integer attribute whose minimum value is 0 whose maximum value is 4"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps65( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps65(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps66( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::NVVM::TensormapElemtypeAttr>(attr))) || ((::llvm::isa<::mlir::NVVM::TensormapInterleaveLayoutAttr>(attr))) || ((::llvm::isa<::mlir::NVVM::TensormapSwizzleModeAttr>(attr))) || ((::llvm::isa<::mlir::NVVM::TensormapSwizzleAtomicityAttr>(attr))) || ((::llvm::isa<::mlir::NVVM::TensormapFillModeAttr>(attr))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM Tensormap Elemtype or NVVM Tensormap Interleave Layout or NVVM Tensormap Swizzle Mode or NVVM Tensormap Swizzle Atomicity or NVVM Tensormap Fill Mode"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps66( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps66(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps67( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::VoteSyncKindAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM vote sync kind"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps67( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps67(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps68( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::MMAFragAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM MMA frag type"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps68( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps68(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps69( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::WGMMATypesAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: NVVM WGMMA types"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps69( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps69(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps70( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::WGMMAScaleOutAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: WGMMA input predicate"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps70( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps70(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps71( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::NVVM::WGMMAScaleInAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: WGMMA overflow options"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_NVVMOps71( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_NVVMOps71(attr, attrName, [op]() { return op->emitOpError(); }); } namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::AddFOp definitions //===----------------------------------------------------------------------===// namespace detail { AddFOpGenericAdaptorBase::AddFOpGenericAdaptorBase(AddFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::FPRoundingModeAttr AddFOpGenericAdaptorBase::getRndAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::FPRoundingModeAttr>(getProperties().rnd); return attr; } ::mlir::NVVM::FPRoundingMode AddFOpGenericAdaptorBase::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::NVVM::SaturationModeAttr AddFOpGenericAdaptorBase::getSatAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::SaturationModeAttr>(getProperties().sat); return attr; } ::mlir::NVVM::SaturationMode AddFOpGenericAdaptorBase::getSat() { auto attr = getSatAttr(); return attr.getValue(); } ::mlir::BoolAttr AddFOpGenericAdaptorBase::getFtzAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().ftz); return attr; } bool AddFOpGenericAdaptorBase::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } } // namespace detail AddFOpAdaptor::AddFOpAdaptor(AddFOp op) : AddFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AddFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (tblgen_rnd && !(((::llvm::isa<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd))) && (((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::NONE)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RM)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RN)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RP)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RZ))))) return emitError(loc, "'nvvm.addf' op attribute 'rnd' failed to satisfy constraint: NVVM FPRoundingMode kind whose value is one of {none, rm, rn, rp, rz}"); if (tblgen_sat && !(((::llvm::isa<::mlir::NVVM::SaturationModeAttr>(tblgen_sat))) && (((::llvm::cast<::mlir::NVVM::SaturationModeAttr>(tblgen_sat).getValue() == ::mlir::NVVM::SaturationMode::NONE)) || ((::llvm::cast<::mlir::NVVM::SaturationModeAttr>(tblgen_sat).getValue() == ::mlir::NVVM::SaturationMode::SAT))))) return emitError(loc, "'nvvm.addf' op attribute 'sat' failed to satisfy constraint: Describes the saturation mode whose value is one of {none, sat}"); if (tblgen_ftz && !((::llvm::isa<::mlir::BoolAttr>(tblgen_ftz)))) return emitError(loc, "'nvvm.addf' op attribute 'ftz' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult AddFOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.ftz; auto attr = dict.get("ftz"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ftz` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.rnd; auto attr = dict.get("rnd"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `rnd` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sat; auto attr = dict.get("sat"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sat` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute AddFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.ftz; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ftz", propStorage)); } { const auto &propStorage = prop.rnd; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("rnd", propStorage)); } { const auto &propStorage = prop.sat; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sat", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code AddFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.ftz.getAsOpaquePointer()), llvm::hash_value(prop.rnd.getAsOpaquePointer()), llvm::hash_value(prop.sat.getAsOpaquePointer())); } std::optional AddFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "ftz") return prop.ftz; if (name == "rnd") return prop.rnd; if (name == "sat") return prop.sat; return std::nullopt; } void AddFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "ftz") { prop.ftz = ::llvm::dyn_cast_or_null>(value); return; } if (name == "rnd") { prop.rnd = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sat") { prop.sat = ::llvm::dyn_cast_or_null>(value); return; } } void AddFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.ftz) attrs.append("ftz", prop.ftz); if (prop.rnd) attrs.append("rnd", prop.rnd); if (prop.sat) attrs.append("sat", prop.sat); } ::llvm::LogicalResult AddFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFtzAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "ftz", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRndAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps1(attr, "rnd", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSatAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps2(attr, "sat", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult AddFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.ftz))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.rnd))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.sat))) return ::mlir::failure(); return ::mlir::success(); } void AddFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.ftz); writer.writeOptionalAttribute(prop.rnd); writer.writeOptionalAttribute(prop.sat); } ::mlir::NVVM::FPRoundingMode AddFOp::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::NVVM::SaturationMode AddFOp::getSat() { auto attr = getSatAttr(); return attr.getValue(); } bool AddFOp::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } void AddFOp::setRnd(::mlir::NVVM::FPRoundingMode attrValue) { getProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void AddFOp::setSat(::mlir::NVVM::SaturationMode attrValue) { getProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void AddFOp::setFtz(bool attrValue) { getProperties().ftz = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (ftz) { odsState.getOrAddProperties().ftz = ftz; } odsState.addTypes(res); } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (ftz) { odsState.getOrAddProperties().ftz = ftz; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AddFOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (ftz) { odsState.getOrAddProperties().ftz = ftz; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); odsState.addTypes(res); } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AddFOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); } void AddFOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AddFOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void AddFOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AddFOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void AddFOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.rnd) properties.rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), FPRoundingMode::NONE); if (!properties.sat) properties.sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE); if (!properties.ftz) properties.ftz = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult AddFOp::verifyInvariantsImpl() { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps1(*this, tblgen_rnd, "rnd"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps2(*this, tblgen_sat, "sat"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_ftz, "ftz"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps1(*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_NVVMOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult AddFOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult AddFOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); if (operands.size() <= 0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[0].getType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult AddFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); if (parser.resolveOperands(lhsOperands, resTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void AddFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getRndAttr(); if(attr && (attr == ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), FPRoundingMode::NONE))) elidedAttrs.push_back("rnd"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getSatAttr(); if(attr && (attr == ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE))) elidedAttrs.push_back("sat"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFtzAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("ftz"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void AddFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::AddFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::AddFOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::AggrSmemSize definitions //===----------------------------------------------------------------------===// namespace detail { AggrSmemSizeGenericAdaptorBase::AggrSmemSizeGenericAdaptorBase(AggrSmemSize op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail AggrSmemSizeAdaptor::AggrSmemSizeAdaptor(AggrSmemSize op) : AggrSmemSizeGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AggrSmemSizeAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult AggrSmemSize::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 AggrSmemSize::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 AggrSmemSize::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional AggrSmemSize::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void AggrSmemSize::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void AggrSmemSize::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult AggrSmemSize::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void AggrSmemSize::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } AggrSmemSize AggrSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AggrSmemSize AggrSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void AggrSmemSize::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AggrSmemSize::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } AggrSmemSize AggrSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AggrSmemSize AggrSmemSize::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void AggrSmemSize::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } AggrSmemSize AggrSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AggrSmemSize AggrSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void AggrSmemSize::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); } AggrSmemSize AggrSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AggrSmemSize AggrSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void AggrSmemSize::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AggrSmemSize::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } AggrSmemSize AggrSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AggrSmemSize AggrSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void AggrSmemSize::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AggrSmemSize AggrSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AggrSmemSize AggrSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void AggrSmemSize::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AggrSmemSize::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } AggrSmemSize AggrSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AggrSmemSize AggrSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult AggrSmemSize::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult AggrSmemSize::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult AggrSmemSize::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult AggrSmemSize::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void AggrSmemSize::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void AggrSmemSize::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::AggrSmemSize) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::BarrierArriveOp definitions //===----------------------------------------------------------------------===// namespace detail { BarrierArriveOpGenericAdaptorBase::BarrierArriveOpGenericAdaptorBase(BarrierArriveOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair BarrierArriveOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {true, false}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::BoolAttr BarrierArriveOpGenericAdaptorBase::getAlignedAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().aligned); return attr; } bool BarrierArriveOpGenericAdaptorBase::getAligned() { auto attr = getAlignedAttr(); return attr.getValue(); } } // namespace detail BarrierArriveOpAdaptor::BarrierArriveOpAdaptor(BarrierArriveOp op) : BarrierArriveOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult BarrierArriveOpAdaptor::verify(::mlir::Location loc) { auto tblgen_aligned = getProperties().aligned; (void)tblgen_aligned; if (tblgen_aligned && !((::llvm::isa<::mlir::BoolAttr>(tblgen_aligned)))) return emitError(loc, "'nvvm.barrier.arrive' op attribute 'aligned' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair BarrierArriveOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {true, false}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 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 BarrierArriveOp::getBarrierIdMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult BarrierArriveOp::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.aligned; auto attr = dict.get("aligned"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `aligned` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute BarrierArriveOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.aligned; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("aligned", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code BarrierArriveOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.aligned.getAsOpaquePointer())); } std::optional BarrierArriveOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "aligned") return prop.aligned; return std::nullopt; } void BarrierArriveOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "aligned") { prop.aligned = ::llvm::dyn_cast_or_null>(value); return; } } void BarrierArriveOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.aligned) attrs.append("aligned", prop.aligned); } ::llvm::LogicalResult BarrierArriveOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAlignedAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "aligned", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult BarrierArriveOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.aligned))) return ::mlir::failure(); return ::mlir::success(); } void BarrierArriveOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.aligned); } bool BarrierArriveOp::getAligned() { auto attr = getAlignedAttr(); return attr.getValue(); } void BarrierArriveOp::setAligned(bool attrValue) { getProperties().aligned = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void BarrierArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value barrierId, ::mlir::Value numberOfThreads, ::mlir::BoolAttr aligned) { if (barrierId) odsState.addOperands(barrierId); odsState.addOperands(numberOfThreads); if (aligned) { odsState.getOrAddProperties().aligned = aligned; } } BarrierArriveOp BarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value barrierId, ::mlir::Value numberOfThreads, ::mlir::BoolAttr aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(barrierId), std::forward(numberOfThreads), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierArriveOp BarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value barrierId, ::mlir::Value numberOfThreads, ::mlir::BoolAttr aligned) { return create(builder, builder.getLoc(), std::forward(barrierId), std::forward(numberOfThreads), std::forward(aligned)); } void BarrierArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, ::mlir::Value numberOfThreads, ::mlir::BoolAttr aligned) { if (barrierId) odsState.addOperands(barrierId); odsState.addOperands(numberOfThreads); if (aligned) { odsState.getOrAddProperties().aligned = aligned; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } BarrierArriveOp BarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, ::mlir::Value numberOfThreads, ::mlir::BoolAttr aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(barrierId), std::forward(numberOfThreads), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierArriveOp BarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, ::mlir::Value numberOfThreads, ::mlir::BoolAttr aligned) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(barrierId), std::forward(numberOfThreads), std::forward(aligned)); } void BarrierArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value barrierId, ::mlir::Value numberOfThreads, bool aligned) { if (barrierId) odsState.addOperands(barrierId); odsState.addOperands(numberOfThreads); odsState.getOrAddProperties().aligned = odsBuilder.getBoolAttr(aligned); } BarrierArriveOp BarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value barrierId, ::mlir::Value numberOfThreads, bool aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(barrierId), std::forward(numberOfThreads), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierArriveOp BarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value barrierId, ::mlir::Value numberOfThreads, bool aligned) { return create(builder, builder.getLoc(), std::forward(barrierId), std::forward(numberOfThreads), std::forward(aligned)); } void BarrierArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, ::mlir::Value numberOfThreads, bool aligned) { if (barrierId) odsState.addOperands(barrierId); odsState.addOperands(numberOfThreads); odsState.getOrAddProperties().aligned = odsBuilder.getBoolAttr(aligned); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } BarrierArriveOp BarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, ::mlir::Value numberOfThreads, bool aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(barrierId), std::forward(numberOfThreads), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierArriveOp BarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, ::mlir::Value numberOfThreads, bool aligned) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(barrierId), std::forward(numberOfThreads), std::forward(aligned)); } void BarrierArriveOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } BarrierArriveOp BarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierArriveOp BarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void BarrierArriveOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } BarrierArriveOp BarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierArriveOp BarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void BarrierArriveOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.aligned) properties.aligned = odsBuilder.getBoolAttr(true); } ::llvm::LogicalResult BarrierArriveOp::verifyInvariantsImpl() { auto tblgen_aligned = getProperties().aligned; (void)tblgen_aligned; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_aligned, "aligned"))) 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_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult BarrierArriveOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult BarrierArriveOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> barrierIdOperands; ::llvm::SMLoc barrierIdOperandsLoc; (void)barrierIdOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand numberOfThreadsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> numberOfThreadsOperands(&numberOfThreadsRawOperand, 1); ::llvm::SMLoc numberOfThreadsOperandsLoc; (void)numberOfThreadsOperandsLoc; if (::mlir::succeeded(parser.parseOptionalKeyword("id"))) { if (parser.parseEqual()) return ::mlir::failure(); { barrierIdOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); barrierIdOperands.push_back(operand); } } } if (parser.parseKeyword("number_of_threads")) return ::mlir::failure(); if (parser.parseEqual()) return ::mlir::failure(); numberOfThreadsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(numberOfThreadsRawOperand)) 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(); } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); if (!barrierIdOperands.empty()) { if (parser.resolveOperands(barrierIdOperands, odsBuildableType0, barrierIdOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(numberOfThreadsOperands, odsBuildableType0, numberOfThreadsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void BarrierArriveOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getBarrierId()) { _odsPrinter << ' ' << "id"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getBarrierId()) _odsPrinter << value; } _odsPrinter << ' ' << "number_of_threads"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; _odsPrinter << getNumberOfThreads(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getAlignedAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("aligned"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::BarrierArriveOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::BarrierArriveOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::BarrierOp definitions //===----------------------------------------------------------------------===// namespace detail { BarrierOpGenericAdaptorBase::BarrierOpGenericAdaptorBase(BarrierOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair BarrierOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::BoolAttr BarrierOpGenericAdaptorBase::getAlignedAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().aligned); return attr; } bool BarrierOpGenericAdaptorBase::getAligned() { auto attr = getAlignedAttr(); return attr.getValue(); } } // namespace detail BarrierOpAdaptor::BarrierOpAdaptor(BarrierOp op) : BarrierOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult BarrierOpAdaptor::verify(::mlir::Location loc) { auto tblgen_aligned = getProperties().aligned; (void)tblgen_aligned; if (tblgen_aligned && !((::llvm::isa<::mlir::BoolAttr>(tblgen_aligned)))) return emitError(loc, "'nvvm.barrier' op attribute 'aligned' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair BarrierOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange BarrierOp::getBarrierIdMutable() { 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 BarrierOp::getNumberOfThreadsMutable() { 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 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(); } { auto &propStorage = prop.aligned; auto attr = dict.get("aligned"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `aligned` 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 BarrierOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.aligned; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("aligned", 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 BarrierOp::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.aligned.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional BarrierOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "aligned") return prop.aligned; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void BarrierOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "aligned") { prop.aligned = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void BarrierOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.aligned) attrs.append("aligned", prop.aligned); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult BarrierOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAlignedAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "aligned", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult BarrierOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.aligned))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void BarrierOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.aligned); 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 BarrierOp::getAligned() { auto attr = getAlignedAttr(); return attr.getValue(); } void BarrierOp::setAligned(bool attrValue) { getProperties().aligned = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void BarrierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { return build(odsBuilder, odsState, Value{}, Value{}); } BarrierOp BarrierOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierOp BarrierOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void BarrierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value barrierId, /*optional*/::mlir::Value numberOfThreads, ::mlir::BoolAttr aligned) { if (barrierId) odsState.addOperands(barrierId); if (numberOfThreads) odsState.addOperands(numberOfThreads); ::llvm::copy(::llvm::ArrayRef({(barrierId ? 1 : 0), (numberOfThreads ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (aligned) { odsState.getOrAddProperties().aligned = aligned; } } BarrierOp BarrierOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value barrierId, /*optional*/::mlir::Value numberOfThreads, ::mlir::BoolAttr aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(barrierId), std::forward(numberOfThreads), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierOp BarrierOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value barrierId, /*optional*/::mlir::Value numberOfThreads, ::mlir::BoolAttr aligned) { return create(builder, builder.getLoc(), std::forward(barrierId), std::forward(numberOfThreads), std::forward(aligned)); } void BarrierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, /*optional*/::mlir::Value numberOfThreads, ::mlir::BoolAttr aligned) { if (barrierId) odsState.addOperands(barrierId); if (numberOfThreads) odsState.addOperands(numberOfThreads); ::llvm::copy(::llvm::ArrayRef({(barrierId ? 1 : 0), (numberOfThreads ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (aligned) { odsState.getOrAddProperties().aligned = aligned; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } BarrierOp BarrierOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, /*optional*/::mlir::Value numberOfThreads, ::mlir::BoolAttr aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(barrierId), std::forward(numberOfThreads), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierOp BarrierOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, /*optional*/::mlir::Value numberOfThreads, ::mlir::BoolAttr aligned) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(barrierId), std::forward(numberOfThreads), std::forward(aligned)); } void BarrierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value barrierId, /*optional*/::mlir::Value numberOfThreads, bool aligned) { if (barrierId) odsState.addOperands(barrierId); if (numberOfThreads) odsState.addOperands(numberOfThreads); ::llvm::copy(::llvm::ArrayRef({(barrierId ? 1 : 0), (numberOfThreads ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().aligned = odsBuilder.getBoolAttr(aligned); } BarrierOp BarrierOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value barrierId, /*optional*/::mlir::Value numberOfThreads, bool aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(barrierId), std::forward(numberOfThreads), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierOp BarrierOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value barrierId, /*optional*/::mlir::Value numberOfThreads, bool aligned) { return create(builder, builder.getLoc(), std::forward(barrierId), std::forward(numberOfThreads), std::forward(aligned)); } void BarrierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, /*optional*/::mlir::Value numberOfThreads, bool aligned) { if (barrierId) odsState.addOperands(barrierId); if (numberOfThreads) odsState.addOperands(numberOfThreads); ::llvm::copy(::llvm::ArrayRef({(barrierId ? 1 : 0), (numberOfThreads ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().aligned = odsBuilder.getBoolAttr(aligned); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } BarrierOp BarrierOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, /*optional*/::mlir::Value numberOfThreads, bool aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(barrierId), std::forward(numberOfThreads), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierOp BarrierOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, /*optional*/::mlir::Value numberOfThreads, bool aligned) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(barrierId), std::forward(numberOfThreads), std::forward(aligned)); } void BarrierOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } 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(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierOp BarrierOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void BarrierOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } 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(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } 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(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void BarrierOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.aligned) properties.aligned = odsBuilder.getBoolAttr(true); } ::llvm::LogicalResult BarrierOp::verifyInvariantsImpl() { auto tblgen_aligned = getProperties().aligned; (void)tblgen_aligned; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_aligned, "aligned"))) 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_NVVMOps2(*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_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult BarrierOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult BarrierOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> barrierIdOperands; ::llvm::SMLoc barrierIdOperandsLoc; (void)barrierIdOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> numberOfThreadsOperands; ::llvm::SMLoc numberOfThreadsOperandsLoc; (void)numberOfThreadsOperandsLoc; if (::mlir::succeeded(parser.parseOptionalKeyword("id"))) { if (parser.parseEqual()) return ::mlir::failure(); { barrierIdOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); barrierIdOperands.push_back(operand); } } } if (::mlir::succeeded(parser.parseOptionalKeyword("number_of_threads"))) { if (parser.parseEqual()) return ::mlir::failure(); { numberOfThreadsOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); numberOfThreadsOperands.push_back(operand); } } } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({static_cast(barrierIdOperands.size()), static_cast(numberOfThreadsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); if (!barrierIdOperands.empty()) { if (parser.resolveOperands(barrierIdOperands, odsBuildableType0, barrierIdOperandsLoc, result.operands)) return ::mlir::failure(); } if (!numberOfThreadsOperands.empty()) { if (parser.resolveOperands(numberOfThreadsOperands, odsBuildableType0, numberOfThreadsOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void BarrierOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getBarrierId()) { _odsPrinter << ' ' << "id"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getBarrierId()) _odsPrinter << value; } if (getNumberOfThreads()) { _odsPrinter << ' ' << "number_of_threads"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getNumberOfThreads()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getAlignedAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("aligned"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::BarrierOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::BarrierOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::BarrierReductionOp definitions //===----------------------------------------------------------------------===// namespace detail { BarrierReductionOpGenericAdaptorBase::BarrierReductionOpGenericAdaptorBase(BarrierReductionOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair BarrierReductionOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {true, false}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 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::NVVM::BarrierReduction BarrierReductionOpGenericAdaptorBase::getReductionOp() { auto attr = getReductionOpAttr(); return attr.getValue(); } ::mlir::BoolAttr BarrierReductionOpGenericAdaptorBase::getAlignedAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().aligned); return attr; } bool BarrierReductionOpGenericAdaptorBase::getAligned() { auto attr = getAlignedAttr(); return attr.getValue(); } } // namespace detail BarrierReductionOpAdaptor::BarrierReductionOpAdaptor(BarrierReductionOp op) : BarrierReductionOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult BarrierReductionOpAdaptor::verify(::mlir::Location loc) { auto tblgen_aligned = getProperties().aligned; (void)tblgen_aligned; auto tblgen_reductionOp = getProperties().reductionOp; (void)tblgen_reductionOp; if (!tblgen_reductionOp) return emitError(loc, "'nvvm.barrier.reduction' op requires attribute 'reductionOp'"); if (tblgen_reductionOp && !((::llvm::isa<::mlir::NVVM::BarrierReductionAttr>(tblgen_reductionOp)))) return emitError(loc, "'nvvm.barrier.reduction' op attribute 'reductionOp' failed to satisfy constraint: NVVM barrier reduction operation"); if (tblgen_aligned && !((::llvm::isa<::mlir::BoolAttr>(tblgen_aligned)))) return emitError(loc, "'nvvm.barrier.reduction' op attribute 'aligned' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair BarrierReductionOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {true, false}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 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 BarrierReductionOp::getBarrierIdMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult BarrierReductionOp::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.aligned; auto attr = dict.get("aligned"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `aligned` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.reductionOp; auto attr = dict.get("reductionOp"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `reductionOp` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute BarrierReductionOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.aligned; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("aligned", propStorage)); } { const auto &propStorage = prop.reductionOp; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("reductionOp", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code BarrierReductionOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.aligned.getAsOpaquePointer()), llvm::hash_value(prop.reductionOp.getAsOpaquePointer())); } std::optional BarrierReductionOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "aligned") return prop.aligned; if (name == "reductionOp") return prop.reductionOp; return std::nullopt; } void BarrierReductionOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "aligned") { prop.aligned = ::llvm::dyn_cast_or_null>(value); return; } if (name == "reductionOp") { prop.reductionOp = ::llvm::dyn_cast_or_null>(value); return; } } void BarrierReductionOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.aligned) attrs.append("aligned", prop.aligned); if (prop.reductionOp) attrs.append("reductionOp", prop.reductionOp); } ::llvm::LogicalResult BarrierReductionOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAlignedAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "aligned", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReductionOpAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps4(attr, "reductionOp", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult BarrierReductionOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.aligned))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.reductionOp))) return ::mlir::failure(); return ::mlir::success(); } void BarrierReductionOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.aligned); writer.writeAttribute(prop.reductionOp); } ::mlir::NVVM::BarrierReduction BarrierReductionOp::getReductionOp() { auto attr = getReductionOpAttr(); return attr.getValue(); } bool BarrierReductionOp::getAligned() { auto attr = getAlignedAttr(); return attr.getValue(); } void BarrierReductionOp::setReductionOp(::mlir::NVVM::BarrierReduction attrValue) { getProperties().reductionOp = ::mlir::NVVM::BarrierReductionAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void BarrierReductionOp::setAligned(bool attrValue) { getProperties().aligned = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void BarrierReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReductionAttr reductionOp, ::mlir::Value reductionPredicate, ::mlir::BoolAttr aligned) { if (barrierId) odsState.addOperands(barrierId); odsState.addOperands(reductionPredicate); odsState.getOrAddProperties().reductionOp = reductionOp; if (aligned) { odsState.getOrAddProperties().aligned = aligned; } odsState.addTypes(res); } BarrierReductionOp BarrierReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReductionAttr reductionOp, ::mlir::Value reductionPredicate, ::mlir::BoolAttr aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(barrierId), std::forward(reductionOp), std::forward(reductionPredicate), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierReductionOp BarrierReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReductionAttr reductionOp, ::mlir::Value reductionPredicate, ::mlir::BoolAttr aligned) { return create(builder, builder.getLoc(), std::forward(res), std::forward(barrierId), std::forward(reductionOp), std::forward(reductionPredicate), std::forward(aligned)); } void BarrierReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReductionAttr reductionOp, ::mlir::Value reductionPredicate, ::mlir::BoolAttr aligned) { if (barrierId) odsState.addOperands(barrierId); odsState.addOperands(reductionPredicate); odsState.getOrAddProperties().reductionOp = reductionOp; if (aligned) { odsState.getOrAddProperties().aligned = aligned; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BarrierReductionOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } BarrierReductionOp BarrierReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReductionAttr reductionOp, ::mlir::Value reductionPredicate, ::mlir::BoolAttr aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(barrierId), std::forward(reductionOp), std::forward(reductionPredicate), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierReductionOp BarrierReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReductionAttr reductionOp, ::mlir::Value reductionPredicate, ::mlir::BoolAttr aligned) { return create(builder, builder.getLoc(), std::forward(barrierId), std::forward(reductionOp), std::forward(reductionPredicate), std::forward(aligned)); } void BarrierReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReductionAttr reductionOp, ::mlir::Value reductionPredicate, ::mlir::BoolAttr aligned) { if (barrierId) odsState.addOperands(barrierId); odsState.addOperands(reductionPredicate); odsState.getOrAddProperties().reductionOp = reductionOp; if (aligned) { odsState.getOrAddProperties().aligned = aligned; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } BarrierReductionOp BarrierReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReductionAttr reductionOp, ::mlir::Value reductionPredicate, ::mlir::BoolAttr aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(barrierId), std::forward(reductionOp), std::forward(reductionPredicate), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierReductionOp BarrierReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReductionAttr reductionOp, ::mlir::Value reductionPredicate, ::mlir::BoolAttr aligned) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(barrierId), std::forward(reductionOp), std::forward(reductionPredicate), std::forward(aligned)); } void BarrierReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReduction reductionOp, ::mlir::Value reductionPredicate, bool aligned) { if (barrierId) odsState.addOperands(barrierId); odsState.addOperands(reductionPredicate); odsState.getOrAddProperties().reductionOp = ::mlir::NVVM::BarrierReductionAttr::get(odsBuilder.getContext(), reductionOp); odsState.getOrAddProperties().aligned = odsBuilder.getBoolAttr(aligned); odsState.addTypes(res); } BarrierReductionOp BarrierReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReduction reductionOp, ::mlir::Value reductionPredicate, bool aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(barrierId), std::forward(reductionOp), std::forward(reductionPredicate), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierReductionOp BarrierReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReduction reductionOp, ::mlir::Value reductionPredicate, bool aligned) { return create(builder, builder.getLoc(), std::forward(res), std::forward(barrierId), std::forward(reductionOp), std::forward(reductionPredicate), std::forward(aligned)); } void BarrierReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReduction reductionOp, ::mlir::Value reductionPredicate, bool aligned) { if (barrierId) odsState.addOperands(barrierId); odsState.addOperands(reductionPredicate); odsState.getOrAddProperties().reductionOp = ::mlir::NVVM::BarrierReductionAttr::get(odsBuilder.getContext(), reductionOp); odsState.getOrAddProperties().aligned = odsBuilder.getBoolAttr(aligned); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BarrierReductionOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } BarrierReductionOp BarrierReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReduction reductionOp, ::mlir::Value reductionPredicate, bool aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(barrierId), std::forward(reductionOp), std::forward(reductionPredicate), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierReductionOp BarrierReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReduction reductionOp, ::mlir::Value reductionPredicate, bool aligned) { return create(builder, builder.getLoc(), std::forward(barrierId), std::forward(reductionOp), std::forward(reductionPredicate), std::forward(aligned)); } void BarrierReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReduction reductionOp, ::mlir::Value reductionPredicate, bool aligned) { if (barrierId) odsState.addOperands(barrierId); odsState.addOperands(reductionPredicate); odsState.getOrAddProperties().reductionOp = ::mlir::NVVM::BarrierReductionAttr::get(odsBuilder.getContext(), reductionOp); odsState.getOrAddProperties().aligned = odsBuilder.getBoolAttr(aligned); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } BarrierReductionOp BarrierReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReduction reductionOp, ::mlir::Value reductionPredicate, bool aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(barrierId), std::forward(reductionOp), std::forward(reductionPredicate), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierReductionOp BarrierReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value barrierId, ::mlir::NVVM::BarrierReduction reductionOp, ::mlir::Value reductionPredicate, bool aligned) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(barrierId), std::forward(reductionOp), std::forward(reductionPredicate), std::forward(aligned)); } void BarrierReductionOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } BarrierReductionOp BarrierReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierReductionOp BarrierReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void BarrierReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BarrierReductionOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BarrierReductionOp BarrierReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierReductionOp BarrierReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void BarrierReductionOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } BarrierReductionOp BarrierReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierReductionOp BarrierReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void BarrierReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BarrierReductionOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BarrierReductionOp BarrierReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BarrierReductionOp BarrierReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void BarrierReductionOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.aligned) properties.aligned = odsBuilder.getBoolAttr(true); } ::llvm::LogicalResult BarrierReductionOp::verifyInvariantsImpl() { auto tblgen_aligned = getProperties().aligned; (void)tblgen_aligned; auto tblgen_reductionOp = getProperties().reductionOp; (void)tblgen_reductionOp; if (!tblgen_reductionOp) return emitOpError("requires attribute 'reductionOp'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps4(*this, tblgen_reductionOp, "reductionOp"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_aligned, "aligned"))) 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_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult BarrierReductionOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult BarrierReductionOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult BarrierReductionOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::BarrierReductionAttr reductionOpAttr; ::mlir::OpAsmParser::UnresolvedOperand reductionPredicateRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> reductionPredicateOperands(&reductionPredicateRawOperand, 1); ::llvm::SMLoc reductionPredicateOperandsLoc; (void)reductionPredicateOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> barrierIdOperands; ::llvm::SMLoc barrierIdOperandsLoc; (void)barrierIdOperandsLoc; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (parser.parseAttribute(reductionOpAttr, ::mlir::Type{})) return ::mlir::failure(); if (reductionOpAttr) result.getOrAddProperties().reductionOp = reductionOpAttr; reductionPredicateOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(reductionPredicateRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("id"))) { if (parser.parseEqual()) return ::mlir::failure(); { barrierIdOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); barrierIdOperands.push_back(operand); } } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); result.addTypes(resTypes); if (!barrierIdOperands.empty()) { if (parser.resolveOperands(barrierIdOperands, odsBuildableType0, barrierIdOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(reductionPredicateOperands, odsBuildableType0, reductionPredicateOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void BarrierReductionOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printAttribute(getReductionOpAttr()); _odsPrinter << ' '; _odsPrinter << getReductionPredicate(); if (getBarrierId()) { _odsPrinter << ' ' << "id"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getBarrierId()) _odsPrinter << value; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("reductionOp"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getAlignedAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("aligned"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::BarrierReductionOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::BarrierReductionOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::BlockDimXOp definitions //===----------------------------------------------------------------------===// namespace detail { BlockDimXOpGenericAdaptorBase::BlockDimXOpGenericAdaptorBase(BlockDimXOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockDimXOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail BlockDimXOpAdaptor::BlockDimXOpAdaptor(BlockDimXOp op) : BlockDimXOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult BlockDimXOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.ntid.x' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult BlockDimXOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute BlockDimXOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code BlockDimXOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional BlockDimXOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void BlockDimXOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void BlockDimXOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult BlockDimXOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult BlockDimXOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void BlockDimXOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockDimXOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void BlockDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } BlockDimXOp BlockDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimXOp BlockDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void BlockDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } BlockDimXOp BlockDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimXOp BlockDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void BlockDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockDimXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } BlockDimXOp BlockDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimXOp BlockDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void BlockDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } BlockDimXOp BlockDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimXOp BlockDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void BlockDimXOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } BlockDimXOp BlockDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimXOp BlockDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void BlockDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockDimXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockDimXOp BlockDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimXOp BlockDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void BlockDimXOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } BlockDimXOp BlockDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimXOp BlockDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void BlockDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockDimXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockDimXOp BlockDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimXOp BlockDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult BlockDimXOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult BlockDimXOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult BlockDimXOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult BlockDimXOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void BlockDimXOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void BlockDimXOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void BlockDimXOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult BlockDimXOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::BlockDimXOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::BlockDimXOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::BlockDimYOp definitions //===----------------------------------------------------------------------===// namespace detail { BlockDimYOpGenericAdaptorBase::BlockDimYOpGenericAdaptorBase(BlockDimYOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockDimYOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail BlockDimYOpAdaptor::BlockDimYOpAdaptor(BlockDimYOp op) : BlockDimYOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult BlockDimYOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.ntid.y' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult BlockDimYOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute BlockDimYOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code BlockDimYOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional BlockDimYOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void BlockDimYOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void BlockDimYOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult BlockDimYOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult BlockDimYOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void BlockDimYOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockDimYOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void BlockDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } BlockDimYOp BlockDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimYOp BlockDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void BlockDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } BlockDimYOp BlockDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimYOp BlockDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void BlockDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockDimYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } BlockDimYOp BlockDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimYOp BlockDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void BlockDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } BlockDimYOp BlockDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimYOp BlockDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void BlockDimYOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } BlockDimYOp BlockDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimYOp BlockDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void BlockDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockDimYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockDimYOp BlockDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimYOp BlockDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void BlockDimYOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } BlockDimYOp BlockDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimYOp BlockDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void BlockDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockDimYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockDimYOp BlockDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimYOp BlockDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult BlockDimYOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult BlockDimYOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult BlockDimYOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult BlockDimYOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void BlockDimYOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void BlockDimYOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void BlockDimYOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult BlockDimYOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::BlockDimYOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::BlockDimYOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::BlockDimZOp definitions //===----------------------------------------------------------------------===// namespace detail { BlockDimZOpGenericAdaptorBase::BlockDimZOpGenericAdaptorBase(BlockDimZOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockDimZOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail BlockDimZOpAdaptor::BlockDimZOpAdaptor(BlockDimZOp op) : BlockDimZOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult BlockDimZOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.ntid.z' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult BlockDimZOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute BlockDimZOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code BlockDimZOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional BlockDimZOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void BlockDimZOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void BlockDimZOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult BlockDimZOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult BlockDimZOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void BlockDimZOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockDimZOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void BlockDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } BlockDimZOp BlockDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimZOp BlockDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void BlockDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } BlockDimZOp BlockDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimZOp BlockDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void BlockDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockDimZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } BlockDimZOp BlockDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimZOp BlockDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void BlockDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } BlockDimZOp BlockDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimZOp BlockDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void BlockDimZOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } BlockDimZOp BlockDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimZOp BlockDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void BlockDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockDimZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockDimZOp BlockDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimZOp BlockDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void BlockDimZOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } BlockDimZOp BlockDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimZOp BlockDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void BlockDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockDimZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockDimZOp BlockDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockDimZOp BlockDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult BlockDimZOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult BlockDimZOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult BlockDimZOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult BlockDimZOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void BlockDimZOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void BlockDimZOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void BlockDimZOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult BlockDimZOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::BlockDimZOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::BlockDimZOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::BlockIdXOp definitions //===----------------------------------------------------------------------===// namespace detail { BlockIdXOpGenericAdaptorBase::BlockIdXOpGenericAdaptorBase(BlockIdXOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockIdXOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail BlockIdXOpAdaptor::BlockIdXOpAdaptor(BlockIdXOp op) : BlockIdXOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult BlockIdXOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.ctaid.x' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult BlockIdXOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute BlockIdXOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code BlockIdXOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional BlockIdXOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void BlockIdXOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void BlockIdXOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult BlockIdXOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult BlockIdXOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void BlockIdXOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockIdXOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void BlockIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } BlockIdXOp BlockIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdXOp BlockIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void BlockIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } BlockIdXOp BlockIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdXOp BlockIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void BlockIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockIdXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } BlockIdXOp BlockIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdXOp BlockIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void BlockIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } BlockIdXOp BlockIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdXOp BlockIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void BlockIdXOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } BlockIdXOp BlockIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdXOp BlockIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void BlockIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockIdXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockIdXOp BlockIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdXOp BlockIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void BlockIdXOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } BlockIdXOp BlockIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdXOp BlockIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void BlockIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockIdXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockIdXOp BlockIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdXOp BlockIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult BlockIdXOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult BlockIdXOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult BlockIdXOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult BlockIdXOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void BlockIdXOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void BlockIdXOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void BlockIdXOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult BlockIdXOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::BlockIdXOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::BlockIdXOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::BlockIdYOp definitions //===----------------------------------------------------------------------===// namespace detail { BlockIdYOpGenericAdaptorBase::BlockIdYOpGenericAdaptorBase(BlockIdYOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockIdYOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail BlockIdYOpAdaptor::BlockIdYOpAdaptor(BlockIdYOp op) : BlockIdYOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult BlockIdYOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.ctaid.y' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult BlockIdYOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute BlockIdYOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code BlockIdYOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional BlockIdYOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void BlockIdYOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void BlockIdYOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult BlockIdYOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult BlockIdYOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void BlockIdYOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockIdYOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void BlockIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } BlockIdYOp BlockIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdYOp BlockIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void BlockIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } BlockIdYOp BlockIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdYOp BlockIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void BlockIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockIdYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } BlockIdYOp BlockIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdYOp BlockIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void BlockIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } BlockIdYOp BlockIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdYOp BlockIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void BlockIdYOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } BlockIdYOp BlockIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdYOp BlockIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void BlockIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockIdYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockIdYOp BlockIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdYOp BlockIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void BlockIdYOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } BlockIdYOp BlockIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdYOp BlockIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void BlockIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockIdYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockIdYOp BlockIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdYOp BlockIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult BlockIdYOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult BlockIdYOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult BlockIdYOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult BlockIdYOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void BlockIdYOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void BlockIdYOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void BlockIdYOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult BlockIdYOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::BlockIdYOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::BlockIdYOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::BlockIdZOp definitions //===----------------------------------------------------------------------===// namespace detail { BlockIdZOpGenericAdaptorBase::BlockIdZOpGenericAdaptorBase(BlockIdZOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockIdZOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail BlockIdZOpAdaptor::BlockIdZOpAdaptor(BlockIdZOp op) : BlockIdZOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult BlockIdZOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.ctaid.z' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult BlockIdZOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute BlockIdZOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code BlockIdZOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional BlockIdZOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void BlockIdZOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void BlockIdZOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult BlockIdZOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult BlockIdZOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void BlockIdZOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockIdZOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void BlockIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } BlockIdZOp BlockIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdZOp BlockIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void BlockIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } BlockIdZOp BlockIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdZOp BlockIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void BlockIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockIdZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } BlockIdZOp BlockIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdZOp BlockIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void BlockIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } BlockIdZOp BlockIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdZOp BlockIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void BlockIdZOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } BlockIdZOp BlockIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdZOp BlockIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void BlockIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockIdZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockIdZOp BlockIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdZOp BlockIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void BlockIdZOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } BlockIdZOp BlockIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdZOp BlockIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void BlockIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockIdZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockIdZOp BlockIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockIdZOp BlockIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult BlockIdZOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult BlockIdZOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult BlockIdZOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult BlockIdZOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void BlockIdZOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void BlockIdZOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void BlockIdZOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult BlockIdZOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::BlockIdZOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::BlockIdZOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::BlockInClusterIdXOp definitions //===----------------------------------------------------------------------===// namespace detail { BlockInClusterIdXOpGenericAdaptorBase::BlockInClusterIdXOpGenericAdaptorBase(BlockInClusterIdXOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockInClusterIdXOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail BlockInClusterIdXOpAdaptor::BlockInClusterIdXOpAdaptor(BlockInClusterIdXOp op) : BlockInClusterIdXOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult BlockInClusterIdXOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.cluster.ctaid.x' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult BlockInClusterIdXOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute BlockInClusterIdXOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code BlockInClusterIdXOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional BlockInClusterIdXOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void BlockInClusterIdXOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void BlockInClusterIdXOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult BlockInClusterIdXOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult BlockInClusterIdXOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void BlockInClusterIdXOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockInClusterIdXOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void BlockInClusterIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } BlockInClusterIdXOp BlockInClusterIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdXOp BlockInClusterIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void BlockInClusterIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } BlockInClusterIdXOp BlockInClusterIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdXOp BlockInClusterIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void BlockInClusterIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockInClusterIdXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } BlockInClusterIdXOp BlockInClusterIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdXOp BlockInClusterIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void BlockInClusterIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } BlockInClusterIdXOp BlockInClusterIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdXOp BlockInClusterIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void BlockInClusterIdXOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } BlockInClusterIdXOp BlockInClusterIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdXOp BlockInClusterIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void BlockInClusterIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockInClusterIdXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockInClusterIdXOp BlockInClusterIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdXOp BlockInClusterIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void BlockInClusterIdXOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } BlockInClusterIdXOp BlockInClusterIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdXOp BlockInClusterIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void BlockInClusterIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockInClusterIdXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockInClusterIdXOp BlockInClusterIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdXOp BlockInClusterIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult BlockInClusterIdXOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult BlockInClusterIdXOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult BlockInClusterIdXOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult BlockInClusterIdXOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void BlockInClusterIdXOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void BlockInClusterIdXOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void BlockInClusterIdXOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult BlockInClusterIdXOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::BlockInClusterIdXOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::BlockInClusterIdXOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::BlockInClusterIdYOp definitions //===----------------------------------------------------------------------===// namespace detail { BlockInClusterIdYOpGenericAdaptorBase::BlockInClusterIdYOpGenericAdaptorBase(BlockInClusterIdYOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockInClusterIdYOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail BlockInClusterIdYOpAdaptor::BlockInClusterIdYOpAdaptor(BlockInClusterIdYOp op) : BlockInClusterIdYOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult BlockInClusterIdYOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.cluster.ctaid.y' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult BlockInClusterIdYOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute BlockInClusterIdYOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code BlockInClusterIdYOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional BlockInClusterIdYOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void BlockInClusterIdYOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void BlockInClusterIdYOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult BlockInClusterIdYOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult BlockInClusterIdYOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void BlockInClusterIdYOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockInClusterIdYOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void BlockInClusterIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } BlockInClusterIdYOp BlockInClusterIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdYOp BlockInClusterIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void BlockInClusterIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } BlockInClusterIdYOp BlockInClusterIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdYOp BlockInClusterIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void BlockInClusterIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockInClusterIdYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } BlockInClusterIdYOp BlockInClusterIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdYOp BlockInClusterIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void BlockInClusterIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } BlockInClusterIdYOp BlockInClusterIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdYOp BlockInClusterIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void BlockInClusterIdYOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } BlockInClusterIdYOp BlockInClusterIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdYOp BlockInClusterIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void BlockInClusterIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockInClusterIdYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockInClusterIdYOp BlockInClusterIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdYOp BlockInClusterIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void BlockInClusterIdYOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } BlockInClusterIdYOp BlockInClusterIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdYOp BlockInClusterIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void BlockInClusterIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockInClusterIdYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockInClusterIdYOp BlockInClusterIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdYOp BlockInClusterIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult BlockInClusterIdYOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult BlockInClusterIdYOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult BlockInClusterIdYOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult BlockInClusterIdYOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void BlockInClusterIdYOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void BlockInClusterIdYOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void BlockInClusterIdYOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult BlockInClusterIdYOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::BlockInClusterIdYOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::BlockInClusterIdYOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::BlockInClusterIdZOp definitions //===----------------------------------------------------------------------===// namespace detail { BlockInClusterIdZOpGenericAdaptorBase::BlockInClusterIdZOpGenericAdaptorBase(BlockInClusterIdZOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockInClusterIdZOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail BlockInClusterIdZOpAdaptor::BlockInClusterIdZOpAdaptor(BlockInClusterIdZOp op) : BlockInClusterIdZOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult BlockInClusterIdZOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.cluster.ctaid.z' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult BlockInClusterIdZOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute BlockInClusterIdZOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code BlockInClusterIdZOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional BlockInClusterIdZOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void BlockInClusterIdZOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void BlockInClusterIdZOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult BlockInClusterIdZOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult BlockInClusterIdZOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void BlockInClusterIdZOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> BlockInClusterIdZOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void BlockInClusterIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } BlockInClusterIdZOp BlockInClusterIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdZOp BlockInClusterIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void BlockInClusterIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } BlockInClusterIdZOp BlockInClusterIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdZOp BlockInClusterIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void BlockInClusterIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockInClusterIdZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } BlockInClusterIdZOp BlockInClusterIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdZOp BlockInClusterIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void BlockInClusterIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } BlockInClusterIdZOp BlockInClusterIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdZOp BlockInClusterIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void BlockInClusterIdZOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } BlockInClusterIdZOp BlockInClusterIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdZOp BlockInClusterIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void BlockInClusterIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockInClusterIdZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockInClusterIdZOp BlockInClusterIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdZOp BlockInClusterIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void BlockInClusterIdZOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } BlockInClusterIdZOp BlockInClusterIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdZOp BlockInClusterIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void BlockInClusterIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(BlockInClusterIdZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } BlockInClusterIdZOp BlockInClusterIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BlockInClusterIdZOp BlockInClusterIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult BlockInClusterIdZOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult BlockInClusterIdZOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult BlockInClusterIdZOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult BlockInClusterIdZOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void BlockInClusterIdZOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void BlockInClusterIdZOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void BlockInClusterIdZOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult BlockInClusterIdZOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::BlockInClusterIdZOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::BlockInClusterIdZOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Breakpoint definitions //===----------------------------------------------------------------------===// namespace detail { BreakpointGenericAdaptorBase::BreakpointGenericAdaptorBase(Breakpoint op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail BreakpointAdaptor::BreakpointAdaptor(Breakpoint op) : BreakpointGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult BreakpointAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult Breakpoint::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 Breakpoint::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 Breakpoint::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional Breakpoint::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void Breakpoint::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void Breakpoint::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult Breakpoint::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void Breakpoint::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { } Breakpoint Breakpoint::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Breakpoint Breakpoint::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void Breakpoint::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Breakpoint Breakpoint::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Breakpoint Breakpoint::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void Breakpoint::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); } Breakpoint Breakpoint::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Breakpoint Breakpoint::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Breakpoint::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Breakpoint Breakpoint::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Breakpoint Breakpoint::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult Breakpoint::verifyInvariantsImpl() { return ::mlir::success(); } ::llvm::LogicalResult Breakpoint::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult Breakpoint::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 Breakpoint::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Breakpoint) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::BulkStoreOp definitions //===----------------------------------------------------------------------===// namespace detail { BulkStoreOpGenericAdaptorBase::BulkStoreOpGenericAdaptorBase(BulkStoreOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::IntegerAttr BulkStoreOpGenericAdaptorBase::getInitValAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().initVal); return attr; } uint64_t BulkStoreOpGenericAdaptorBase::getInitVal() { auto attr = getInitValAttr(); return attr.getValue().getZExtValue(); } } // namespace detail BulkStoreOpAdaptor::BulkStoreOpAdaptor(BulkStoreOp op) : BulkStoreOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult BulkStoreOpAdaptor::verify(::mlir::Location loc) { auto tblgen_initVal = getProperties().initVal; (void)tblgen_initVal; if (tblgen_initVal && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_initVal))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_initVal).getType().isSignlessInteger(64))))) return emitError(loc, "'nvvm.st.bulk' op attribute 'initVal' failed to satisfy constraint: 64-bit signless integer attribute"); return ::mlir::success(); } ::llvm::LogicalResult BulkStoreOp::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.initVal; auto attr = dict.get("initVal"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `initVal` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute BulkStoreOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.initVal; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("initVal", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code BulkStoreOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.initVal.getAsOpaquePointer())); } std::optional BulkStoreOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "initVal") return prop.initVal; return std::nullopt; } void BulkStoreOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "initVal") { prop.initVal = ::llvm::dyn_cast_or_null>(value); return; } } void BulkStoreOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.initVal) attrs.append("initVal", prop.initVal); } ::llvm::LogicalResult BulkStoreOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getInitValAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps6(attr, "initVal", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult BulkStoreOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.initVal))) return ::mlir::failure(); return ::mlir::success(); } void BulkStoreOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.initVal); } uint64_t BulkStoreOp::getInitVal() { auto attr = getInitValAttr(); return attr.getValue().getZExtValue(); } void BulkStoreOp::setInitVal(uint64_t attrValue) { getProperties().initVal = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); } void BulkStoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value size, ::mlir::IntegerAttr initVal) { odsState.addOperands(addr); odsState.addOperands(size); if (initVal) { odsState.getOrAddProperties().initVal = initVal; } } BulkStoreOp BulkStoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value size, ::mlir::IntegerAttr initVal) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(size), std::forward(initVal)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BulkStoreOp BulkStoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value size, ::mlir::IntegerAttr initVal) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(size), std::forward(initVal)); } void BulkStoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value size, ::mlir::IntegerAttr initVal) { odsState.addOperands(addr); odsState.addOperands(size); if (initVal) { odsState.getOrAddProperties().initVal = initVal; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } BulkStoreOp BulkStoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value size, ::mlir::IntegerAttr initVal) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(size), std::forward(initVal)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BulkStoreOp BulkStoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value size, ::mlir::IntegerAttr initVal) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(size), std::forward(initVal)); } void BulkStoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value size, uint64_t initVal) { odsState.addOperands(addr); odsState.addOperands(size); odsState.getOrAddProperties().initVal = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), initVal); } BulkStoreOp BulkStoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value size, uint64_t initVal) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(size), std::forward(initVal)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BulkStoreOp BulkStoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value size, uint64_t initVal) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(size), std::forward(initVal)); } void BulkStoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value size, uint64_t initVal) { odsState.addOperands(addr); odsState.addOperands(size); odsState.getOrAddProperties().initVal = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), initVal); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } BulkStoreOp BulkStoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value size, uint64_t initVal) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(size), std::forward(initVal)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BulkStoreOp BulkStoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value size, uint64_t initVal) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(size), std::forward(initVal)); } void BulkStoreOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } BulkStoreOp BulkStoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BulkStoreOp BulkStoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void BulkStoreOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } BulkStoreOp BulkStoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BulkStoreOp BulkStoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void BulkStoreOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.initVal) properties.initVal = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), 0); } ::llvm::LogicalResult BulkStoreOp::verifyInvariantsImpl() { auto tblgen_initVal = getProperties().initVal; (void)tblgen_initVal; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps6(*this, tblgen_initVal, "initVal"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps3(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult BulkStoreOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult BulkStoreOp::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 sizeRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sizeOperands(&sizeRawOperand, 1); ::llvm::SMLoc sizeOperandsLoc; (void)sizeOperandsLoc; ::mlir::IntegerAttr initValAttr; ::mlir::Type addrRawType{}; ::llvm::ArrayRef<::mlir::Type> addrTypes(&addrRawType, 1); addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); if (parser.parseKeyword("size")) return ::mlir::failure(); if (parser.parseEqual()) return ::mlir::failure(); sizeOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sizeRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { if (parser.parseKeyword("init")) return ::mlir::failure(); if (parser.parseEqual()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(initValAttr, parser.getBuilder().getIntegerType(64))) { return ::mlir::failure(); } if (initValAttr) result.getOrAddProperties().initVal = initValAttr; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); addrRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(64); if (parser.resolveOperands(addrOperands, addrTypes, addrOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(sizeOperands, odsBuildableType0, sizeOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void BulkStoreOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); _odsPrinter << ","; _odsPrinter << ' ' << "size"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; _odsPrinter << getSize(); if (getInitValAttr() != ::mlir::OpBuilder((*this)->getContext()).getIntegerAttr(::mlir::OpBuilder((*this)->getContext()).getIntegerType(64), 0)) { _odsPrinter << ","; _odsPrinter << ' ' << "init"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getInitValAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("initVal"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getInitValAttr(); if(attr && (attr == odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), 0))) elidedAttrs.push_back("initVal"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getAddr().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::BulkStoreOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::BulkStoreOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Clock64Op definitions //===----------------------------------------------------------------------===// namespace detail { Clock64OpGenericAdaptorBase::Clock64OpGenericAdaptorBase(Clock64Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail Clock64OpAdaptor::Clock64OpAdaptor(Clock64Op op) : Clock64OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Clock64OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult Clock64Op::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 Clock64Op::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 Clock64Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional Clock64Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void Clock64Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void Clock64Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult Clock64Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void Clock64Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } Clock64Op Clock64Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Clock64Op Clock64Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void Clock64Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(Clock64Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } Clock64Op Clock64Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Clock64Op Clock64Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void Clock64Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } Clock64Op Clock64Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Clock64Op Clock64Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void Clock64Op::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); } Clock64Op Clock64Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Clock64Op Clock64Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Clock64Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(Clock64Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } Clock64Op Clock64Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Clock64Op Clock64Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void Clock64Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Clock64Op Clock64Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Clock64Op Clock64Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Clock64Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(Clock64Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } Clock64Op Clock64Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Clock64Op Clock64Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult Clock64Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Clock64Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult Clock64Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(64); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult Clock64Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void Clock64Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Clock64Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClockOp definitions //===----------------------------------------------------------------------===// namespace detail { ClockOpGenericAdaptorBase::ClockOpGenericAdaptorBase(ClockOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail ClockOpAdaptor::ClockOpAdaptor(ClockOp op) : ClockOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClockOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult ClockOp::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 ClockOp::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 ClockOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional ClockOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void ClockOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void ClockOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult ClockOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void ClockOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } ClockOp ClockOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClockOp ClockOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void ClockOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClockOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ClockOp ClockOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClockOp ClockOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void ClockOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClockOp ClockOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClockOp ClockOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void ClockOp::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); } ClockOp ClockOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClockOp ClockOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClockOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClockOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClockOp ClockOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClockOp ClockOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ClockOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClockOp ClockOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClockOp ClockOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ClockOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClockOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClockOp ClockOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClockOp ClockOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClockOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ClockOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult ClockOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ClockOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void ClockOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClockOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClusterArriveOp definitions //===----------------------------------------------------------------------===// namespace detail { ClusterArriveOpGenericAdaptorBase::ClusterArriveOpGenericAdaptorBase(ClusterArriveOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional ClusterArriveOpGenericAdaptorBase::getAligned() { auto attr = getAlignedAttr(); return attr ? ::std::optional(attr != nullptr) : (::std::nullopt); } } // namespace detail ClusterArriveOpAdaptor::ClusterArriveOpAdaptor(ClusterArriveOp op) : ClusterArriveOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClusterArriveOpAdaptor::verify(::mlir::Location loc) { auto tblgen_aligned = getProperties().aligned; (void)tblgen_aligned; if (tblgen_aligned && !((::llvm::isa<::mlir::UnitAttr>(tblgen_aligned)))) return emitError(loc, "'nvvm.cluster.arrive' op attribute 'aligned' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } ::llvm::LogicalResult ClusterArriveOp::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.aligned; auto attr = dict.get("aligned"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `aligned` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ClusterArriveOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.aligned; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("aligned", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ClusterArriveOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.aligned.getAsOpaquePointer())); } std::optional ClusterArriveOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "aligned") return prop.aligned; return std::nullopt; } void ClusterArriveOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "aligned") { prop.aligned = ::llvm::dyn_cast_or_null>(value); return; } } void ClusterArriveOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.aligned) attrs.append("aligned", prop.aligned); } ::llvm::LogicalResult ClusterArriveOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAlignedAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "aligned", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ClusterArriveOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.aligned))) return ::mlir::failure(); return ::mlir::success(); } void ClusterArriveOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.aligned); } ::std::optional ClusterArriveOp::getAligned() { auto attr = getAlignedAttr(); return attr ? ::std::optional(attr != nullptr) : (::std::nullopt); } void ClusterArriveOp::setAligned(bool attrValue) { auto &odsProp = getProperties().aligned; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void ClusterArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::UnitAttr aligned) { if (aligned) { odsState.getOrAddProperties().aligned = aligned; } } ClusterArriveOp ClusterArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::UnitAttr aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterArriveOp ClusterArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::UnitAttr aligned) { return create(builder, builder.getLoc(), std::forward(aligned)); } void ClusterArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr aligned) { if (aligned) { odsState.getOrAddProperties().aligned = aligned; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterArriveOp ClusterArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterArriveOp ClusterArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr aligned) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(aligned)); } void ClusterArriveOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ClusterArriveOp ClusterArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterArriveOp ClusterArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClusterArriveOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClusterArriveOp ClusterArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterArriveOp ClusterArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClusterArriveOp::verifyInvariantsImpl() { auto tblgen_aligned = getProperties().aligned; (void)tblgen_aligned; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_aligned, "aligned"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult ClusterArriveOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ClusterArriveOp::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 ClusterArriveOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClusterArriveOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ClusterArriveOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClusterArriveRelaxedOp definitions //===----------------------------------------------------------------------===// namespace detail { ClusterArriveRelaxedOpGenericAdaptorBase::ClusterArriveRelaxedOpGenericAdaptorBase(ClusterArriveRelaxedOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional ClusterArriveRelaxedOpGenericAdaptorBase::getAligned() { auto attr = getAlignedAttr(); return attr ? ::std::optional(attr != nullptr) : (::std::nullopt); } } // namespace detail ClusterArriveRelaxedOpAdaptor::ClusterArriveRelaxedOpAdaptor(ClusterArriveRelaxedOp op) : ClusterArriveRelaxedOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClusterArriveRelaxedOpAdaptor::verify(::mlir::Location loc) { auto tblgen_aligned = getProperties().aligned; (void)tblgen_aligned; if (tblgen_aligned && !((::llvm::isa<::mlir::UnitAttr>(tblgen_aligned)))) return emitError(loc, "'nvvm.cluster.arrive.relaxed' op attribute 'aligned' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } ::llvm::LogicalResult ClusterArriveRelaxedOp::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.aligned; auto attr = dict.get("aligned"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `aligned` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ClusterArriveRelaxedOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.aligned; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("aligned", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ClusterArriveRelaxedOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.aligned.getAsOpaquePointer())); } std::optional ClusterArriveRelaxedOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "aligned") return prop.aligned; return std::nullopt; } void ClusterArriveRelaxedOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "aligned") { prop.aligned = ::llvm::dyn_cast_or_null>(value); return; } } void ClusterArriveRelaxedOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.aligned) attrs.append("aligned", prop.aligned); } ::llvm::LogicalResult ClusterArriveRelaxedOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAlignedAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "aligned", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ClusterArriveRelaxedOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.aligned))) return ::mlir::failure(); return ::mlir::success(); } void ClusterArriveRelaxedOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.aligned); } ::std::optional ClusterArriveRelaxedOp::getAligned() { auto attr = getAlignedAttr(); return attr ? ::std::optional(attr != nullptr) : (::std::nullopt); } void ClusterArriveRelaxedOp::setAligned(bool attrValue) { auto &odsProp = getProperties().aligned; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void ClusterArriveRelaxedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::UnitAttr aligned) { if (aligned) { odsState.getOrAddProperties().aligned = aligned; } } ClusterArriveRelaxedOp ClusterArriveRelaxedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::UnitAttr aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterArriveRelaxedOp ClusterArriveRelaxedOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::UnitAttr aligned) { return create(builder, builder.getLoc(), std::forward(aligned)); } void ClusterArriveRelaxedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr aligned) { if (aligned) { odsState.getOrAddProperties().aligned = aligned; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterArriveRelaxedOp ClusterArriveRelaxedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterArriveRelaxedOp ClusterArriveRelaxedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr aligned) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(aligned)); } void ClusterArriveRelaxedOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ClusterArriveRelaxedOp ClusterArriveRelaxedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterArriveRelaxedOp ClusterArriveRelaxedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClusterArriveRelaxedOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClusterArriveRelaxedOp ClusterArriveRelaxedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterArriveRelaxedOp ClusterArriveRelaxedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClusterArriveRelaxedOp::verifyInvariantsImpl() { auto tblgen_aligned = getProperties().aligned; (void)tblgen_aligned; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_aligned, "aligned"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult ClusterArriveRelaxedOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ClusterArriveRelaxedOp::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 ClusterArriveRelaxedOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClusterArriveRelaxedOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ClusterArriveRelaxedOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClusterDim definitions //===----------------------------------------------------------------------===// namespace detail { ClusterDimGenericAdaptorBase::ClusterDimGenericAdaptorBase(ClusterDim op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterDimGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail ClusterDimAdaptor::ClusterDimAdaptor(ClusterDim op) : ClusterDimGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClusterDimAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.cluster.nctarank' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult ClusterDim::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ClusterDim::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ClusterDim::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional ClusterDim::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void ClusterDim::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void ClusterDim::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult ClusterDim::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ClusterDim::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void ClusterDim::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterDim::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void ClusterDim::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } ClusterDim ClusterDim::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDim ClusterDim::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void ClusterDim::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } ClusterDim ClusterDim::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDim ClusterDim::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void ClusterDim::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDim::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ClusterDim ClusterDim::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDim ClusterDim::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void ClusterDim::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterDim ClusterDim::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDim ClusterDim::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void ClusterDim::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ClusterDim ClusterDim::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDim ClusterDim::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClusterDim::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDim::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterDim ClusterDim::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDim ClusterDim::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ClusterDim::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClusterDim ClusterDim::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDim ClusterDim::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ClusterDim::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDim::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterDim ClusterDim::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDim ClusterDim::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClusterDim::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ClusterDim::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ClusterDim::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ClusterDim::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void ClusterDim::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ClusterDim::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void ClusterDim::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult ClusterDim::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClusterDim) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ClusterDimGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClusterDimBlocksXOp definitions //===----------------------------------------------------------------------===// namespace detail { ClusterDimBlocksXOpGenericAdaptorBase::ClusterDimBlocksXOpGenericAdaptorBase(ClusterDimBlocksXOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterDimBlocksXOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail ClusterDimBlocksXOpAdaptor::ClusterDimBlocksXOpAdaptor(ClusterDimBlocksXOp op) : ClusterDimBlocksXOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClusterDimBlocksXOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.cluster.nctaid.x' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult ClusterDimBlocksXOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ClusterDimBlocksXOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ClusterDimBlocksXOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional ClusterDimBlocksXOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void ClusterDimBlocksXOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void ClusterDimBlocksXOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult ClusterDimBlocksXOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ClusterDimBlocksXOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void ClusterDimBlocksXOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterDimBlocksXOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void ClusterDimBlocksXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } ClusterDimBlocksXOp ClusterDimBlocksXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksXOp ClusterDimBlocksXOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void ClusterDimBlocksXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } ClusterDimBlocksXOp ClusterDimBlocksXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksXOp ClusterDimBlocksXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void ClusterDimBlocksXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimBlocksXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ClusterDimBlocksXOp ClusterDimBlocksXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksXOp ClusterDimBlocksXOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void ClusterDimBlocksXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterDimBlocksXOp ClusterDimBlocksXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksXOp ClusterDimBlocksXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void ClusterDimBlocksXOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ClusterDimBlocksXOp ClusterDimBlocksXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksXOp ClusterDimBlocksXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClusterDimBlocksXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimBlocksXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterDimBlocksXOp ClusterDimBlocksXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksXOp ClusterDimBlocksXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ClusterDimBlocksXOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClusterDimBlocksXOp ClusterDimBlocksXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksXOp ClusterDimBlocksXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ClusterDimBlocksXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimBlocksXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterDimBlocksXOp ClusterDimBlocksXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksXOp ClusterDimBlocksXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClusterDimBlocksXOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ClusterDimBlocksXOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ClusterDimBlocksXOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ClusterDimBlocksXOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void ClusterDimBlocksXOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ClusterDimBlocksXOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void ClusterDimBlocksXOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult ClusterDimBlocksXOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClusterDimBlocksXOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ClusterDimBlocksXOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClusterDimBlocksYOp definitions //===----------------------------------------------------------------------===// namespace detail { ClusterDimBlocksYOpGenericAdaptorBase::ClusterDimBlocksYOpGenericAdaptorBase(ClusterDimBlocksYOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterDimBlocksYOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail ClusterDimBlocksYOpAdaptor::ClusterDimBlocksYOpAdaptor(ClusterDimBlocksYOp op) : ClusterDimBlocksYOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClusterDimBlocksYOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.cluster.nctaid.y' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult ClusterDimBlocksYOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ClusterDimBlocksYOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ClusterDimBlocksYOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional ClusterDimBlocksYOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void ClusterDimBlocksYOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void ClusterDimBlocksYOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult ClusterDimBlocksYOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ClusterDimBlocksYOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void ClusterDimBlocksYOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterDimBlocksYOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void ClusterDimBlocksYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } ClusterDimBlocksYOp ClusterDimBlocksYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksYOp ClusterDimBlocksYOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void ClusterDimBlocksYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } ClusterDimBlocksYOp ClusterDimBlocksYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksYOp ClusterDimBlocksYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void ClusterDimBlocksYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimBlocksYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ClusterDimBlocksYOp ClusterDimBlocksYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksYOp ClusterDimBlocksYOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void ClusterDimBlocksYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterDimBlocksYOp ClusterDimBlocksYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksYOp ClusterDimBlocksYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void ClusterDimBlocksYOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ClusterDimBlocksYOp ClusterDimBlocksYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksYOp ClusterDimBlocksYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClusterDimBlocksYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimBlocksYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterDimBlocksYOp ClusterDimBlocksYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksYOp ClusterDimBlocksYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ClusterDimBlocksYOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClusterDimBlocksYOp ClusterDimBlocksYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksYOp ClusterDimBlocksYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ClusterDimBlocksYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimBlocksYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterDimBlocksYOp ClusterDimBlocksYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksYOp ClusterDimBlocksYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClusterDimBlocksYOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ClusterDimBlocksYOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ClusterDimBlocksYOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ClusterDimBlocksYOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void ClusterDimBlocksYOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ClusterDimBlocksYOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void ClusterDimBlocksYOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult ClusterDimBlocksYOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClusterDimBlocksYOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ClusterDimBlocksYOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClusterDimBlocksZOp definitions //===----------------------------------------------------------------------===// namespace detail { ClusterDimBlocksZOpGenericAdaptorBase::ClusterDimBlocksZOpGenericAdaptorBase(ClusterDimBlocksZOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterDimBlocksZOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail ClusterDimBlocksZOpAdaptor::ClusterDimBlocksZOpAdaptor(ClusterDimBlocksZOp op) : ClusterDimBlocksZOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClusterDimBlocksZOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.cluster.nctaid.z' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult ClusterDimBlocksZOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ClusterDimBlocksZOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ClusterDimBlocksZOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional ClusterDimBlocksZOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void ClusterDimBlocksZOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void ClusterDimBlocksZOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult ClusterDimBlocksZOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ClusterDimBlocksZOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void ClusterDimBlocksZOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterDimBlocksZOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void ClusterDimBlocksZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } ClusterDimBlocksZOp ClusterDimBlocksZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksZOp ClusterDimBlocksZOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void ClusterDimBlocksZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } ClusterDimBlocksZOp ClusterDimBlocksZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksZOp ClusterDimBlocksZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void ClusterDimBlocksZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimBlocksZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ClusterDimBlocksZOp ClusterDimBlocksZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksZOp ClusterDimBlocksZOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void ClusterDimBlocksZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterDimBlocksZOp ClusterDimBlocksZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksZOp ClusterDimBlocksZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void ClusterDimBlocksZOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ClusterDimBlocksZOp ClusterDimBlocksZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksZOp ClusterDimBlocksZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClusterDimBlocksZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimBlocksZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterDimBlocksZOp ClusterDimBlocksZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksZOp ClusterDimBlocksZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ClusterDimBlocksZOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClusterDimBlocksZOp ClusterDimBlocksZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksZOp ClusterDimBlocksZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ClusterDimBlocksZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimBlocksZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterDimBlocksZOp ClusterDimBlocksZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimBlocksZOp ClusterDimBlocksZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClusterDimBlocksZOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ClusterDimBlocksZOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ClusterDimBlocksZOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ClusterDimBlocksZOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void ClusterDimBlocksZOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ClusterDimBlocksZOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void ClusterDimBlocksZOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult ClusterDimBlocksZOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClusterDimBlocksZOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ClusterDimBlocksZOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClusterDimXOp definitions //===----------------------------------------------------------------------===// namespace detail { ClusterDimXOpGenericAdaptorBase::ClusterDimXOpGenericAdaptorBase(ClusterDimXOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterDimXOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail ClusterDimXOpAdaptor::ClusterDimXOpAdaptor(ClusterDimXOp op) : ClusterDimXOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClusterDimXOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.nclusterid.x' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult ClusterDimXOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ClusterDimXOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ClusterDimXOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional ClusterDimXOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void ClusterDimXOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void ClusterDimXOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult ClusterDimXOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ClusterDimXOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void ClusterDimXOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterDimXOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void ClusterDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } ClusterDimXOp ClusterDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimXOp ClusterDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void ClusterDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } ClusterDimXOp ClusterDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimXOp ClusterDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void ClusterDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ClusterDimXOp ClusterDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimXOp ClusterDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void ClusterDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterDimXOp ClusterDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimXOp ClusterDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void ClusterDimXOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ClusterDimXOp ClusterDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimXOp ClusterDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClusterDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterDimXOp ClusterDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimXOp ClusterDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ClusterDimXOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClusterDimXOp ClusterDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimXOp ClusterDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ClusterDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterDimXOp ClusterDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimXOp ClusterDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClusterDimXOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ClusterDimXOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ClusterDimXOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ClusterDimXOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void ClusterDimXOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ClusterDimXOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void ClusterDimXOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult ClusterDimXOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClusterDimXOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ClusterDimXOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClusterDimYOp definitions //===----------------------------------------------------------------------===// namespace detail { ClusterDimYOpGenericAdaptorBase::ClusterDimYOpGenericAdaptorBase(ClusterDimYOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterDimYOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail ClusterDimYOpAdaptor::ClusterDimYOpAdaptor(ClusterDimYOp op) : ClusterDimYOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClusterDimYOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.nclusterid.y' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult ClusterDimYOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ClusterDimYOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ClusterDimYOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional ClusterDimYOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void ClusterDimYOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void ClusterDimYOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult ClusterDimYOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ClusterDimYOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void ClusterDimYOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterDimYOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void ClusterDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } ClusterDimYOp ClusterDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimYOp ClusterDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void ClusterDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } ClusterDimYOp ClusterDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimYOp ClusterDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void ClusterDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ClusterDimYOp ClusterDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimYOp ClusterDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void ClusterDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterDimYOp ClusterDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimYOp ClusterDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void ClusterDimYOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ClusterDimYOp ClusterDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimYOp ClusterDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClusterDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterDimYOp ClusterDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimYOp ClusterDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ClusterDimYOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClusterDimYOp ClusterDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimYOp ClusterDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ClusterDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterDimYOp ClusterDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimYOp ClusterDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClusterDimYOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ClusterDimYOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ClusterDimYOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ClusterDimYOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void ClusterDimYOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ClusterDimYOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void ClusterDimYOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult ClusterDimYOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClusterDimYOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ClusterDimYOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClusterDimZOp definitions //===----------------------------------------------------------------------===// namespace detail { ClusterDimZOpGenericAdaptorBase::ClusterDimZOpGenericAdaptorBase(ClusterDimZOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterDimZOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail ClusterDimZOpAdaptor::ClusterDimZOpAdaptor(ClusterDimZOp op) : ClusterDimZOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClusterDimZOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.nclusterid.z' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult ClusterDimZOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ClusterDimZOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ClusterDimZOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional ClusterDimZOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void ClusterDimZOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void ClusterDimZOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult ClusterDimZOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ClusterDimZOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void ClusterDimZOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterDimZOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void ClusterDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } ClusterDimZOp ClusterDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimZOp ClusterDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void ClusterDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } ClusterDimZOp ClusterDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimZOp ClusterDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void ClusterDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ClusterDimZOp ClusterDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimZOp ClusterDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void ClusterDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterDimZOp ClusterDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimZOp ClusterDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void ClusterDimZOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ClusterDimZOp ClusterDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimZOp ClusterDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClusterDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterDimZOp ClusterDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimZOp ClusterDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ClusterDimZOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClusterDimZOp ClusterDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimZOp ClusterDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ClusterDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterDimZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterDimZOp ClusterDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterDimZOp ClusterDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClusterDimZOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ClusterDimZOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ClusterDimZOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ClusterDimZOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void ClusterDimZOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ClusterDimZOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void ClusterDimZOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult ClusterDimZOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClusterDimZOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ClusterDimZOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClusterId definitions //===----------------------------------------------------------------------===// namespace detail { ClusterIdGenericAdaptorBase::ClusterIdGenericAdaptorBase(ClusterId op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterIdGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail ClusterIdAdaptor::ClusterIdAdaptor(ClusterId op) : ClusterIdGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClusterIdAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.cluster.ctarank' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult ClusterId::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ClusterId::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ClusterId::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional ClusterId::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void ClusterId::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void ClusterId::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult ClusterId::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ClusterId::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void ClusterId::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterId::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void ClusterId::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } ClusterId ClusterId::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterId ClusterId::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void ClusterId::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } ClusterId ClusterId::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterId ClusterId::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void ClusterId::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterId::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ClusterId ClusterId::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterId ClusterId::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void ClusterId::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterId ClusterId::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterId ClusterId::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void ClusterId::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ClusterId ClusterId::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterId ClusterId::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClusterId::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterId::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterId ClusterId::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterId ClusterId::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ClusterId::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClusterId ClusterId::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterId ClusterId::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ClusterId::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterId::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterId ClusterId::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterId ClusterId::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClusterId::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ClusterId::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ClusterId::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ClusterId::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void ClusterId::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ClusterId::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void ClusterId::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult ClusterId::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClusterId) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ClusterIdGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClusterIdXOp definitions //===----------------------------------------------------------------------===// namespace detail { ClusterIdXOpGenericAdaptorBase::ClusterIdXOpGenericAdaptorBase(ClusterIdXOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterIdXOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail ClusterIdXOpAdaptor::ClusterIdXOpAdaptor(ClusterIdXOp op) : ClusterIdXOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClusterIdXOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.clusterid.x' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult ClusterIdXOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ClusterIdXOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ClusterIdXOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional ClusterIdXOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void ClusterIdXOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void ClusterIdXOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult ClusterIdXOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ClusterIdXOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void ClusterIdXOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterIdXOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void ClusterIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } ClusterIdXOp ClusterIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdXOp ClusterIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void ClusterIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } ClusterIdXOp ClusterIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdXOp ClusterIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void ClusterIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterIdXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ClusterIdXOp ClusterIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdXOp ClusterIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void ClusterIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterIdXOp ClusterIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdXOp ClusterIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void ClusterIdXOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ClusterIdXOp ClusterIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdXOp ClusterIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClusterIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterIdXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterIdXOp ClusterIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdXOp ClusterIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ClusterIdXOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClusterIdXOp ClusterIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdXOp ClusterIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ClusterIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterIdXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterIdXOp ClusterIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdXOp ClusterIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClusterIdXOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ClusterIdXOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ClusterIdXOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ClusterIdXOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void ClusterIdXOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ClusterIdXOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void ClusterIdXOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult ClusterIdXOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClusterIdXOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ClusterIdXOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClusterIdYOp definitions //===----------------------------------------------------------------------===// namespace detail { ClusterIdYOpGenericAdaptorBase::ClusterIdYOpGenericAdaptorBase(ClusterIdYOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterIdYOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail ClusterIdYOpAdaptor::ClusterIdYOpAdaptor(ClusterIdYOp op) : ClusterIdYOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClusterIdYOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.clusterid.y' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult ClusterIdYOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ClusterIdYOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ClusterIdYOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional ClusterIdYOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void ClusterIdYOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void ClusterIdYOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult ClusterIdYOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ClusterIdYOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void ClusterIdYOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterIdYOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void ClusterIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } ClusterIdYOp ClusterIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdYOp ClusterIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void ClusterIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } ClusterIdYOp ClusterIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdYOp ClusterIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void ClusterIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterIdYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ClusterIdYOp ClusterIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdYOp ClusterIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void ClusterIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterIdYOp ClusterIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdYOp ClusterIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void ClusterIdYOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ClusterIdYOp ClusterIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdYOp ClusterIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClusterIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterIdYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterIdYOp ClusterIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdYOp ClusterIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ClusterIdYOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClusterIdYOp ClusterIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdYOp ClusterIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ClusterIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterIdYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterIdYOp ClusterIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdYOp ClusterIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClusterIdYOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ClusterIdYOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ClusterIdYOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ClusterIdYOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void ClusterIdYOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ClusterIdYOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void ClusterIdYOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult ClusterIdYOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClusterIdYOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ClusterIdYOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClusterIdZOp definitions //===----------------------------------------------------------------------===// namespace detail { ClusterIdZOpGenericAdaptorBase::ClusterIdZOpGenericAdaptorBase(ClusterIdZOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterIdZOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail ClusterIdZOpAdaptor::ClusterIdZOpAdaptor(ClusterIdZOp op) : ClusterIdZOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClusterIdZOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.clusterid.z' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult ClusterIdZOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ClusterIdZOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ClusterIdZOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional ClusterIdZOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void ClusterIdZOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void ClusterIdZOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult ClusterIdZOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ClusterIdZOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void ClusterIdZOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> ClusterIdZOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void ClusterIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } ClusterIdZOp ClusterIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdZOp ClusterIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void ClusterIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } ClusterIdZOp ClusterIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdZOp ClusterIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void ClusterIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterIdZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ClusterIdZOp ClusterIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdZOp ClusterIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void ClusterIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterIdZOp ClusterIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdZOp ClusterIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void ClusterIdZOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ClusterIdZOp ClusterIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdZOp ClusterIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClusterIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterIdZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterIdZOp ClusterIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdZOp ClusterIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ClusterIdZOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClusterIdZOp ClusterIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdZOp ClusterIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ClusterIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterIdZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterIdZOp ClusterIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterIdZOp ClusterIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClusterIdZOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ClusterIdZOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ClusterIdZOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ClusterIdZOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void ClusterIdZOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ClusterIdZOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void ClusterIdZOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult ClusterIdZOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClusterIdZOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ClusterIdZOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClusterLaunchControlQueryCancelOp definitions //===----------------------------------------------------------------------===// namespace detail { ClusterLaunchControlQueryCancelOpGenericAdaptorBase::ClusterLaunchControlQueryCancelOpGenericAdaptorBase(ClusterLaunchControlQueryCancelOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::ClusterLaunchControlQueryType ClusterLaunchControlQueryCancelOpGenericAdaptorBase::getQueryType() { auto attr = getQueryTypeAttr(); return attr.getValue(); } } // namespace detail ClusterLaunchControlQueryCancelOpAdaptor::ClusterLaunchControlQueryCancelOpAdaptor(ClusterLaunchControlQueryCancelOp op) : ClusterLaunchControlQueryCancelOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClusterLaunchControlQueryCancelOpAdaptor::verify(::mlir::Location loc) { auto tblgen_query_type = getProperties().query_type; (void)tblgen_query_type; if (!tblgen_query_type) return emitError(loc, "'nvvm.clusterlaunchcontrol.query.cancel' op requires attribute 'query_type'"); if (tblgen_query_type && !((::llvm::isa<::mlir::NVVM::ClusterLaunchControlQueryTypeAttr>(tblgen_query_type)))) return emitError(loc, "'nvvm.clusterlaunchcontrol.query.cancel' op attribute 'query_type' failed to satisfy constraint: NVVM ClusterLaunchControlQueryType"); return ::mlir::success(); } ::llvm::LogicalResult ClusterLaunchControlQueryCancelOp::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.query_type; auto attr = dict.get("query_type"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `query_type` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ClusterLaunchControlQueryCancelOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.query_type; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("query_type", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ClusterLaunchControlQueryCancelOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.query_type.getAsOpaquePointer())); } std::optional ClusterLaunchControlQueryCancelOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "query_type") return prop.query_type; return std::nullopt; } void ClusterLaunchControlQueryCancelOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "query_type") { prop.query_type = ::llvm::dyn_cast_or_null>(value); return; } } void ClusterLaunchControlQueryCancelOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.query_type) attrs.append("query_type", prop.query_type); } ::llvm::LogicalResult ClusterLaunchControlQueryCancelOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getQueryTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps8(attr, "query_type", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ClusterLaunchControlQueryCancelOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.query_type))) return ::mlir::failure(); return ::mlir::success(); } void ClusterLaunchControlQueryCancelOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.query_type); } ::mlir::NVVM::ClusterLaunchControlQueryType ClusterLaunchControlQueryCancelOp::getQueryType() { auto attr = getQueryTypeAttr(); return attr.getValue(); } void ClusterLaunchControlQueryCancelOp::setQueryType(::mlir::NVVM::ClusterLaunchControlQueryType attrValue) { getProperties().query_type = ::mlir::NVVM::ClusterLaunchControlQueryTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ClusterLaunchControlQueryCancelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::NVVM::ClusterLaunchControlQueryTypeAttr query_type, ::mlir::Value try_cancel_response) { odsState.addOperands(try_cancel_response); odsState.getOrAddProperties().query_type = query_type; odsState.addTypes(res); } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::NVVM::ClusterLaunchControlQueryTypeAttr query_type, ::mlir::Value try_cancel_response) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(query_type), std::forward(try_cancel_response)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::NVVM::ClusterLaunchControlQueryTypeAttr query_type, ::mlir::Value try_cancel_response) { return create(builder, builder.getLoc(), std::forward(res), std::forward(query_type), std::forward(try_cancel_response)); } void ClusterLaunchControlQueryCancelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::ClusterLaunchControlQueryTypeAttr query_type, ::mlir::Value try_cancel_response) { odsState.addOperands(try_cancel_response); odsState.getOrAddProperties().query_type = query_type; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterLaunchControlQueryCancelOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::ClusterLaunchControlQueryTypeAttr query_type, ::mlir::Value try_cancel_response) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(query_type), std::forward(try_cancel_response)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::ClusterLaunchControlQueryTypeAttr query_type, ::mlir::Value try_cancel_response) { return create(builder, builder.getLoc(), std::forward(query_type), std::forward(try_cancel_response)); } void ClusterLaunchControlQueryCancelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::ClusterLaunchControlQueryTypeAttr query_type, ::mlir::Value try_cancel_response) { odsState.addOperands(try_cancel_response); odsState.getOrAddProperties().query_type = query_type; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::ClusterLaunchControlQueryTypeAttr query_type, ::mlir::Value try_cancel_response) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(query_type), std::forward(try_cancel_response)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::ClusterLaunchControlQueryTypeAttr query_type, ::mlir::Value try_cancel_response) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(query_type), std::forward(try_cancel_response)); } void ClusterLaunchControlQueryCancelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::NVVM::ClusterLaunchControlQueryType query_type, ::mlir::Value try_cancel_response) { odsState.addOperands(try_cancel_response); odsState.getOrAddProperties().query_type = ::mlir::NVVM::ClusterLaunchControlQueryTypeAttr::get(odsBuilder.getContext(), query_type); odsState.addTypes(res); } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::NVVM::ClusterLaunchControlQueryType query_type, ::mlir::Value try_cancel_response) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(query_type), std::forward(try_cancel_response)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::NVVM::ClusterLaunchControlQueryType query_type, ::mlir::Value try_cancel_response) { return create(builder, builder.getLoc(), std::forward(res), std::forward(query_type), std::forward(try_cancel_response)); } void ClusterLaunchControlQueryCancelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::ClusterLaunchControlQueryType query_type, ::mlir::Value try_cancel_response) { odsState.addOperands(try_cancel_response); odsState.getOrAddProperties().query_type = ::mlir::NVVM::ClusterLaunchControlQueryTypeAttr::get(odsBuilder.getContext(), query_type); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterLaunchControlQueryCancelOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::ClusterLaunchControlQueryType query_type, ::mlir::Value try_cancel_response) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(query_type), std::forward(try_cancel_response)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::ClusterLaunchControlQueryType query_type, ::mlir::Value try_cancel_response) { return create(builder, builder.getLoc(), std::forward(query_type), std::forward(try_cancel_response)); } void ClusterLaunchControlQueryCancelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::ClusterLaunchControlQueryType query_type, ::mlir::Value try_cancel_response) { odsState.addOperands(try_cancel_response); odsState.getOrAddProperties().query_type = ::mlir::NVVM::ClusterLaunchControlQueryTypeAttr::get(odsBuilder.getContext(), query_type); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::ClusterLaunchControlQueryType query_type, ::mlir::Value try_cancel_response) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(query_type), std::forward(try_cancel_response)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::ClusterLaunchControlQueryType query_type, ::mlir::Value try_cancel_response) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(query_type), std::forward(try_cancel_response)); } void ClusterLaunchControlQueryCancelOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClusterLaunchControlQueryCancelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterLaunchControlQueryCancelOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ClusterLaunchControlQueryCancelOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ClusterLaunchControlQueryCancelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ClusterLaunchControlQueryCancelOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterLaunchControlQueryCancelOp ClusterLaunchControlQueryCancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClusterLaunchControlQueryCancelOp::verifyInvariantsImpl() { auto tblgen_query_type = getProperties().query_type; (void)tblgen_query_type; if (!tblgen_query_type) return emitOpError("requires attribute 'query_type'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps8(*this, tblgen_query_type, "query_type"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps5(*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_NVVMOps6(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ClusterLaunchControlQueryCancelOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ClusterLaunchControlQueryCancelOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::ClusterLaunchControlQueryTypeAttr query_typeAttr; ::mlir::OpAsmParser::UnresolvedOperand try_cancel_responseRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> try_cancel_responseOperands(&try_cancel_responseRawOperand, 1); ::llvm::SMLoc try_cancel_responseOperandsLoc; (void)try_cancel_responseOperandsLoc; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (parser.parseKeyword("query")) return ::mlir::failure(); if (parser.parseEqual()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(query_typeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (query_typeAttr) result.getOrAddProperties().query_type = query_typeAttr; if (parser.parseComma()) return ::mlir::failure(); try_cancel_responseOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(try_cancel_responseRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(128); result.addTypes(resTypes); if (parser.resolveOperands(try_cancel_responseOperands, odsBuildableType0, try_cancel_responseOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ClusterLaunchControlQueryCancelOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' ' << "query"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getQueryTypeAttr()); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getTryCancelResponse(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("query_type"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } ::llvm::LogicalResult ClusterLaunchControlQueryCancelOp::inferReturnTypes(::mlir::MLIRContext *context, std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { ClusterLaunchControlQueryCancelOp::Adaptor adaptor(operands, attributes, properties, regions); return ClusterLaunchControlQueryCancelOp::inferReturnTypes(context, location, adaptor, inferredReturnTypes); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClusterLaunchControlQueryCancelOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ClusterLaunchControlQueryCancelOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClusterLaunchControlTryCancelOp definitions //===----------------------------------------------------------------------===// namespace detail { ClusterLaunchControlTryCancelOpGenericAdaptorBase::ClusterLaunchControlTryCancelOpGenericAdaptorBase(ClusterLaunchControlTryCancelOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::UnitAttr ClusterLaunchControlTryCancelOpGenericAdaptorBase::getMulticastAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().multicast); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool ClusterLaunchControlTryCancelOpGenericAdaptorBase::getMulticast() { auto attr = getMulticastAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail ClusterLaunchControlTryCancelOpAdaptor::ClusterLaunchControlTryCancelOpAdaptor(ClusterLaunchControlTryCancelOp op) : ClusterLaunchControlTryCancelOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClusterLaunchControlTryCancelOpAdaptor::verify(::mlir::Location loc) { auto tblgen_multicast = getProperties().multicast; (void)tblgen_multicast; if (tblgen_multicast && !((::llvm::isa<::mlir::UnitAttr>(tblgen_multicast)))) return emitError(loc, "'nvvm.clusterlaunchcontrol.try.cancel' op attribute 'multicast' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } ::llvm::LogicalResult ClusterLaunchControlTryCancelOp::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.multicast; auto attr = dict.get("multicast"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multicast` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ClusterLaunchControlTryCancelOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.multicast; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("multicast", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ClusterLaunchControlTryCancelOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.multicast.getAsOpaquePointer())); } std::optional ClusterLaunchControlTryCancelOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "multicast") return prop.multicast; return std::nullopt; } void ClusterLaunchControlTryCancelOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "multicast") { prop.multicast = ::llvm::dyn_cast_or_null>(value); return; } } void ClusterLaunchControlTryCancelOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.multicast) attrs.append("multicast", prop.multicast); } ::llvm::LogicalResult ClusterLaunchControlTryCancelOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getMulticastAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "multicast", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ClusterLaunchControlTryCancelOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.multicast))) return ::mlir::failure(); return ::mlir::success(); } void ClusterLaunchControlTryCancelOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.multicast); } bool ClusterLaunchControlTryCancelOp::getMulticast() { auto attr = getMulticastAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void ClusterLaunchControlTryCancelOp::setMulticast(bool attrValue) { auto &odsProp = getProperties().multicast; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void ClusterLaunchControlTryCancelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::UnitAttr multicast, ::mlir::Value smemAddress, ::mlir::Value mbarrier) { odsState.addOperands(smemAddress); odsState.addOperands(mbarrier); if (multicast) { odsState.getOrAddProperties().multicast = multicast; } } ClusterLaunchControlTryCancelOp ClusterLaunchControlTryCancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::UnitAttr multicast, ::mlir::Value smemAddress, ::mlir::Value mbarrier) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(multicast), std::forward(smemAddress), std::forward(mbarrier)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterLaunchControlTryCancelOp ClusterLaunchControlTryCancelOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::UnitAttr multicast, ::mlir::Value smemAddress, ::mlir::Value mbarrier) { return create(builder, builder.getLoc(), std::forward(multicast), std::forward(smemAddress), std::forward(mbarrier)); } void ClusterLaunchControlTryCancelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr multicast, ::mlir::Value smemAddress, ::mlir::Value mbarrier) { odsState.addOperands(smemAddress); odsState.addOperands(mbarrier); if (multicast) { odsState.getOrAddProperties().multicast = multicast; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterLaunchControlTryCancelOp ClusterLaunchControlTryCancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr multicast, ::mlir::Value smemAddress, ::mlir::Value mbarrier) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(multicast), std::forward(smemAddress), std::forward(mbarrier)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterLaunchControlTryCancelOp ClusterLaunchControlTryCancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr multicast, ::mlir::Value smemAddress, ::mlir::Value mbarrier) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(multicast), std::forward(smemAddress), std::forward(mbarrier)); } void ClusterLaunchControlTryCancelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/bool multicast, ::mlir::Value smemAddress, ::mlir::Value mbarrier) { odsState.addOperands(smemAddress); odsState.addOperands(mbarrier); if (multicast) { odsState.getOrAddProperties().multicast = ((multicast) ? odsBuilder.getUnitAttr() : nullptr); } } ClusterLaunchControlTryCancelOp ClusterLaunchControlTryCancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/bool multicast, ::mlir::Value smemAddress, ::mlir::Value mbarrier) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(multicast), std::forward(smemAddress), std::forward(mbarrier)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterLaunchControlTryCancelOp ClusterLaunchControlTryCancelOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/bool multicast, ::mlir::Value smemAddress, ::mlir::Value mbarrier) { return create(builder, builder.getLoc(), std::forward(multicast), std::forward(smemAddress), std::forward(mbarrier)); } void ClusterLaunchControlTryCancelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/bool multicast, ::mlir::Value smemAddress, ::mlir::Value mbarrier) { odsState.addOperands(smemAddress); odsState.addOperands(mbarrier); if (multicast) { odsState.getOrAddProperties().multicast = ((multicast) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterLaunchControlTryCancelOp ClusterLaunchControlTryCancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/bool multicast, ::mlir::Value smemAddress, ::mlir::Value mbarrier) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(multicast), std::forward(smemAddress), std::forward(mbarrier)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterLaunchControlTryCancelOp ClusterLaunchControlTryCancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/bool multicast, ::mlir::Value smemAddress, ::mlir::Value mbarrier) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(multicast), std::forward(smemAddress), std::forward(mbarrier)); } void ClusterLaunchControlTryCancelOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ClusterLaunchControlTryCancelOp ClusterLaunchControlTryCancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterLaunchControlTryCancelOp ClusterLaunchControlTryCancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClusterLaunchControlTryCancelOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClusterLaunchControlTryCancelOp ClusterLaunchControlTryCancelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterLaunchControlTryCancelOp ClusterLaunchControlTryCancelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClusterLaunchControlTryCancelOp::verifyInvariantsImpl() { auto tblgen_multicast = getProperties().multicast; (void)tblgen_multicast; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_multicast, "multicast"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ClusterLaunchControlTryCancelOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ClusterLaunchControlTryCancelOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand smemAddressRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> smemAddressOperands(&smemAddressRawOperand, 1); ::llvm::SMLoc smemAddressOperandsLoc; (void)smemAddressOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand mbarrierRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> mbarrierOperands(&mbarrierRawOperand, 1); ::llvm::SMLoc mbarrierOperandsLoc; (void)mbarrierOperandsLoc; if (::mlir::succeeded(parser.parseOptionalKeyword("multicast"))) { result.getOrAddProperties().multicast = parser.getBuilder().getUnitAttr(); if (parser.parseComma()) return ::mlir::failure(); } smemAddressOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(smemAddressRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); mbarrierOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(mbarrierRawOperand)) 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(); } ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::LLVM::LLVMPointerType>(3); if (parser.resolveOperands(smemAddressOperands, odsBuildableType0, smemAddressOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(mbarrierOperands, odsBuildableType0, mbarrierOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ClusterLaunchControlTryCancelOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if ((getMulticastAttr() && getMulticastAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "multicast"; _odsPrinter << ","; } _odsPrinter << ' '; _odsPrinter << getSmemAddress(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMbarrier(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("multicast"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getMulticastAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("multicast"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClusterLaunchControlTryCancelOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ClusterLaunchControlTryCancelOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ClusterWaitOp definitions //===----------------------------------------------------------------------===// namespace detail { ClusterWaitOpGenericAdaptorBase::ClusterWaitOpGenericAdaptorBase(ClusterWaitOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional ClusterWaitOpGenericAdaptorBase::getAligned() { auto attr = getAlignedAttr(); return attr ? ::std::optional(attr != nullptr) : (::std::nullopt); } } // namespace detail ClusterWaitOpAdaptor::ClusterWaitOpAdaptor(ClusterWaitOp op) : ClusterWaitOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ClusterWaitOpAdaptor::verify(::mlir::Location loc) { auto tblgen_aligned = getProperties().aligned; (void)tblgen_aligned; if (tblgen_aligned && !((::llvm::isa<::mlir::UnitAttr>(tblgen_aligned)))) return emitError(loc, "'nvvm.cluster.wait' op attribute 'aligned' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } ::llvm::LogicalResult ClusterWaitOp::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.aligned; auto attr = dict.get("aligned"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `aligned` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ClusterWaitOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.aligned; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("aligned", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ClusterWaitOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.aligned.getAsOpaquePointer())); } std::optional ClusterWaitOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "aligned") return prop.aligned; return std::nullopt; } void ClusterWaitOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "aligned") { prop.aligned = ::llvm::dyn_cast_or_null>(value); return; } } void ClusterWaitOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.aligned) attrs.append("aligned", prop.aligned); } ::llvm::LogicalResult ClusterWaitOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAlignedAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "aligned", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ClusterWaitOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.aligned))) return ::mlir::failure(); return ::mlir::success(); } void ClusterWaitOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.aligned); } ::std::optional ClusterWaitOp::getAligned() { auto attr = getAlignedAttr(); return attr ? ::std::optional(attr != nullptr) : (::std::nullopt); } void ClusterWaitOp::setAligned(bool attrValue) { auto &odsProp = getProperties().aligned; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void ClusterWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::UnitAttr aligned) { if (aligned) { odsState.getOrAddProperties().aligned = aligned; } } ClusterWaitOp ClusterWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::UnitAttr aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterWaitOp ClusterWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::UnitAttr aligned) { return create(builder, builder.getLoc(), std::forward(aligned)); } void ClusterWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr aligned) { if (aligned) { odsState.getOrAddProperties().aligned = aligned; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ClusterWaitOp ClusterWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr aligned) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(aligned)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterWaitOp ClusterWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr aligned) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(aligned)); } void ClusterWaitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ClusterWaitOp ClusterWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterWaitOp ClusterWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ClusterWaitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ClusterWaitOp ClusterWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ClusterWaitOp ClusterWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ClusterWaitOp::verifyInvariantsImpl() { auto tblgen_aligned = getProperties().aligned; (void)tblgen_aligned; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_aligned, "aligned"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult ClusterWaitOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ClusterWaitOp::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 ClusterWaitOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ClusterWaitOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ClusterWaitOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertBF16x2ToF4x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertBF16x2ToF4x2OpGenericAdaptorBase::ConvertBF16x2ToF4x2OpGenericAdaptorBase(ConvertBF16x2ToF4x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::BoolAttr ConvertBF16x2ToF4x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertBF16x2ToF4x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertBF16x2ToF4x2OpGenericAdaptorBase::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } } // namespace detail ConvertBF16x2ToF4x2OpAdaptor::ConvertBF16x2ToF4x2OpAdaptor(ConvertBF16x2ToF4x2Op op) : ConvertBF16x2ToF4x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertBF16x2ToF4x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitError(loc, "'nvvm.convert.bf16x2.to.f4x2' op requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.bf16x2.to.f4x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); if (tblgen_dstTy && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_dstTy))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))) && ((::llvm::isa<::mlir::Float4E2M1FNType>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))))) return emitError(loc, "'nvvm.convert.bf16x2.to.f4x2' op attribute 'dstTy' failed to satisfy constraint: type attribute of f4E2M1FN type"); return ::mlir::success(); } ::llvm::LogicalResult ConvertBF16x2ToF4x2Op::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.dstTy; auto attr = dict.get("dstTy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dstTy` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertBF16x2ToF4x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.dstTy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dstTy", propStorage)); } { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertBF16x2ToF4x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.dstTy.getAsOpaquePointer()), llvm::hash_value(prop.relu.getAsOpaquePointer())); } std::optional ConvertBF16x2ToF4x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "dstTy") return prop.dstTy; if (name == "relu") return prop.relu; return std::nullopt; } void ConvertBF16x2ToF4x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "dstTy") { prop.dstTy = ::llvm::dyn_cast_or_null>(value); return; } if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertBF16x2ToF4x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.dstTy) attrs.append("dstTy", prop.dstTy); if (prop.relu) attrs.append("relu", prop.relu); } ::llvm::LogicalResult ConvertBF16x2ToF4x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getDstTyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps9(attr, "dstTy", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertBF16x2ToF4x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.dstTy))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); return ::mlir::success(); } void ConvertBF16x2ToF4x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.dstTy); writer.writeOptionalAttribute(prop.relu); } bool ConvertBF16x2ToF4x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertBF16x2ToF4x2Op::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } void ConvertBF16x2ToF4x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertBF16x2ToF4x2Op::setDstTy(::mlir::Type attrValue) { getProperties().dstTy = ::mlir::TypeAttr::get(attrValue); } void ConvertBF16x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; odsState.addTypes(dst); } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertBF16x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertBF16x2ToF4x2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertBF16x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertBF16x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); odsState.addTypes(dst); } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertBF16x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertBF16x2ToF4x2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertBF16x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertBF16x2ToF4x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertBF16x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertBF16x2ToF4x2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ConvertBF16x2ToF4x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertBF16x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertBF16x2ToF4x2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF4x2Op ConvertBF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertBF16x2ToF4x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertBF16x2ToF4x2Op::verifyInvariantsImpl() { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitOpError("requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps9(*this, tblgen_dstTy, "dstTy"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps8(*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_NVVMOps9(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertBF16x2ToF4x2Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult ConvertBF16x2ToF4x2Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(8); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ConvertBF16x2ToF4x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); ::mlir::TypeAttr dstTyAttr; srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(dstTyAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (dstTyAttr) result.getOrAddProperties().dstTy = dstTyAttr; if (parser.parseRParen()) return ::mlir::failure(); result.addTypes(dstTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertBF16x2ToF4x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("dstTy"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getDstTyAttr()); _odsPrinter << ")"; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertBF16x2ToF4x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertBF16x2ToF4x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertBF16x2ToF6x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertBF16x2ToF6x2OpGenericAdaptorBase::ConvertBF16x2ToF6x2OpGenericAdaptorBase(ConvertBF16x2ToF6x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::BoolAttr ConvertBF16x2ToF6x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertBF16x2ToF6x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertBF16x2ToF6x2OpGenericAdaptorBase::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } } // namespace detail ConvertBF16x2ToF6x2OpAdaptor::ConvertBF16x2ToF6x2OpAdaptor(ConvertBF16x2ToF6x2Op op) : ConvertBF16x2ToF6x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertBF16x2ToF6x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitError(loc, "'nvvm.convert.bf16x2.to.f6x2' op requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.bf16x2.to.f6x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); if (tblgen_dstTy && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_dstTy))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))) && (((::llvm::isa<::mlir::Float6E2M3FNType>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue())))))) return emitError(loc, "'nvvm.convert.bf16x2.to.f6x2' op attribute 'dstTy' failed to satisfy constraint: type attribute of f6E2M3FN type or f6E3M2FN type"); return ::mlir::success(); } ::llvm::LogicalResult ConvertBF16x2ToF6x2Op::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.dstTy; auto attr = dict.get("dstTy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dstTy` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertBF16x2ToF6x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.dstTy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dstTy", propStorage)); } { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertBF16x2ToF6x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.dstTy.getAsOpaquePointer()), llvm::hash_value(prop.relu.getAsOpaquePointer())); } std::optional ConvertBF16x2ToF6x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "dstTy") return prop.dstTy; if (name == "relu") return prop.relu; return std::nullopt; } void ConvertBF16x2ToF6x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "dstTy") { prop.dstTy = ::llvm::dyn_cast_or_null>(value); return; } if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertBF16x2ToF6x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.dstTy) attrs.append("dstTy", prop.dstTy); if (prop.relu) attrs.append("relu", prop.relu); } ::llvm::LogicalResult ConvertBF16x2ToF6x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getDstTyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps10(attr, "dstTy", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertBF16x2ToF6x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.dstTy))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); return ::mlir::success(); } void ConvertBF16x2ToF6x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.dstTy); writer.writeOptionalAttribute(prop.relu); } bool ConvertBF16x2ToF6x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertBF16x2ToF6x2Op::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } void ConvertBF16x2ToF6x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertBF16x2ToF6x2Op::setDstTy(::mlir::Type attrValue) { getProperties().dstTy = ::mlir::TypeAttr::get(attrValue); } void ConvertBF16x2ToF6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; odsState.addTypes(dst); } ConvertBF16x2ToF6x2Op ConvertBF16x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF6x2Op ConvertBF16x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertBF16x2ToF6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertBF16x2ToF6x2Op ConvertBF16x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF6x2Op ConvertBF16x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertBF16x2ToF6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); odsState.addTypes(dst); } ConvertBF16x2ToF6x2Op ConvertBF16x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF6x2Op ConvertBF16x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertBF16x2ToF6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertBF16x2ToF6x2Op ConvertBF16x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF6x2Op ConvertBF16x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertBF16x2ToF6x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertBF16x2ToF6x2Op ConvertBF16x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF6x2Op ConvertBF16x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertBF16x2ToF6x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertBF16x2ToF6x2Op ConvertBF16x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF6x2Op ConvertBF16x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertBF16x2ToF6x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertBF16x2ToF6x2Op::verifyInvariantsImpl() { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitOpError("requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps10(*this, tblgen_dstTy, "dstTy"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps8(*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_NVVMOps10(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertBF16x2ToF6x2Op::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ConvertBF16x2ToF6x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); ::mlir::TypeAttr dstTyAttr; srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(dstTyAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (dstTyAttr) result.getOrAddProperties().dstTy = dstTyAttr; if (parser.parseRParen()) return ::mlir::failure(); result.addTypes(dstTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertBF16x2ToF6x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("dstTy"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getDstTyAttr()); _odsPrinter << ")"; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertBF16x2ToF6x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertBF16x2ToF6x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertBF16x2ToF8x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertBF16x2ToF8x2OpGenericAdaptorBase::ConvertBF16x2ToF8x2OpGenericAdaptorBase(ConvertBF16x2ToF8x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::FPRoundingModeAttr ConvertBF16x2ToF8x2OpGenericAdaptorBase::getRndAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::FPRoundingModeAttr>(getProperties().rnd); return attr; } ::mlir::NVVM::FPRoundingMode ConvertBF16x2ToF8x2OpGenericAdaptorBase::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::NVVM::SaturationModeAttr ConvertBF16x2ToF8x2OpGenericAdaptorBase::getSatAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::SaturationModeAttr>(getProperties().sat); return attr; } ::mlir::NVVM::SaturationMode ConvertBF16x2ToF8x2OpGenericAdaptorBase::getSat() { auto attr = getSatAttr(); return attr.getValue(); } ::mlir::BoolAttr ConvertBF16x2ToF8x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertBF16x2ToF8x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertBF16x2ToF8x2OpGenericAdaptorBase::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } } // namespace detail ConvertBF16x2ToF8x2OpAdaptor::ConvertBF16x2ToF8x2OpAdaptor(ConvertBF16x2ToF8x2Op op) : ConvertBF16x2ToF8x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertBF16x2ToF8x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitError(loc, "'nvvm.convert.bf16x2.to.f8x2' op requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (tblgen_rnd && !((::llvm::isa<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd)))) return emitError(loc, "'nvvm.convert.bf16x2.to.f8x2' op attribute 'rnd' failed to satisfy constraint: NVVM FPRoundingMode kind"); if (tblgen_sat && !((::llvm::isa<::mlir::NVVM::SaturationModeAttr>(tblgen_sat)))) return emitError(loc, "'nvvm.convert.bf16x2.to.f8x2' op attribute 'sat' failed to satisfy constraint: Describes the saturation mode"); if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.bf16x2.to.f8x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); if (tblgen_dstTy && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_dstTy))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))) && (((::llvm::isa<::mlir::Float8E8M0FNUType>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))) || ((::llvm::isa<::mlir::Float8E5M2Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue())))))) return emitError(loc, "'nvvm.convert.bf16x2.to.f8x2' op attribute 'dstTy' failed to satisfy constraint: type attribute of f8E8M0FNU type or f8E4M3FN type or f8E5M2 type"); return ::mlir::success(); } ::llvm::LogicalResult ConvertBF16x2ToF8x2Op::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.dstTy; auto attr = dict.get("dstTy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dstTy` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.rnd; auto attr = dict.get("rnd"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `rnd` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sat; auto attr = dict.get("sat"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sat` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertBF16x2ToF8x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.dstTy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dstTy", propStorage)); } { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } { const auto &propStorage = prop.rnd; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("rnd", propStorage)); } { const auto &propStorage = prop.sat; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sat", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertBF16x2ToF8x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.dstTy.getAsOpaquePointer()), llvm::hash_value(prop.relu.getAsOpaquePointer()), llvm::hash_value(prop.rnd.getAsOpaquePointer()), llvm::hash_value(prop.sat.getAsOpaquePointer())); } std::optional ConvertBF16x2ToF8x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "dstTy") return prop.dstTy; if (name == "relu") return prop.relu; if (name == "rnd") return prop.rnd; if (name == "sat") return prop.sat; return std::nullopt; } void ConvertBF16x2ToF8x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "dstTy") { prop.dstTy = ::llvm::dyn_cast_or_null>(value); return; } if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } if (name == "rnd") { prop.rnd = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sat") { prop.sat = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertBF16x2ToF8x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.dstTy) attrs.append("dstTy", prop.dstTy); if (prop.relu) attrs.append("relu", prop.relu); if (prop.rnd) attrs.append("rnd", prop.rnd); if (prop.sat) attrs.append("sat", prop.sat); } ::llvm::LogicalResult ConvertBF16x2ToF8x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getDstTyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps13(attr, "dstTy", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRndAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps11(attr, "rnd", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSatAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps12(attr, "sat", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertBF16x2ToF8x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.dstTy))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.rnd))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.sat))) return ::mlir::failure(); return ::mlir::success(); } void ConvertBF16x2ToF8x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.dstTy); writer.writeOptionalAttribute(prop.relu); writer.writeOptionalAttribute(prop.rnd); writer.writeOptionalAttribute(prop.sat); } ::mlir::NVVM::FPRoundingMode ConvertBF16x2ToF8x2Op::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::NVVM::SaturationMode ConvertBF16x2ToF8x2Op::getSat() { auto attr = getSatAttr(); return attr.getValue(); } bool ConvertBF16x2ToF8x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertBF16x2ToF8x2Op::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } void ConvertBF16x2ToF8x2Op::setRnd(::mlir::NVVM::FPRoundingMode attrValue) { getProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ConvertBF16x2ToF8x2Op::setSat(::mlir::NVVM::SaturationMode attrValue) { getProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ConvertBF16x2ToF8x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertBF16x2ToF8x2Op::setDstTy(::mlir::Type attrValue) { getProperties().dstTy = ::mlir::TypeAttr::get(attrValue); } void ConvertBF16x2ToF8x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; odsState.addTypes(dst); } ConvertBF16x2ToF8x2Op ConvertBF16x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF8x2Op ConvertBF16x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu), std::forward(dstTy)); } void ConvertBF16x2ToF8x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertBF16x2ToF8x2Op ConvertBF16x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF8x2Op ConvertBF16x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu), std::forward(dstTy)); } void ConvertBF16x2ToF8x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); odsState.addTypes(dst); } ConvertBF16x2ToF8x2Op ConvertBF16x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF8x2Op ConvertBF16x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu), std::forward(dstTy)); } void ConvertBF16x2ToF8x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertBF16x2ToF8x2Op ConvertBF16x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF8x2Op ConvertBF16x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu), std::forward(dstTy)); } void ConvertBF16x2ToF8x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertBF16x2ToF8x2Op ConvertBF16x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF8x2Op ConvertBF16x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertBF16x2ToF8x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertBF16x2ToF8x2Op ConvertBF16x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToF8x2Op ConvertBF16x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertBF16x2ToF8x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.rnd) properties.rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), FPRoundingMode::NONE); if (!properties.sat) properties.sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertBF16x2ToF8x2Op::verifyInvariantsImpl() { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitOpError("requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps11(*this, tblgen_rnd, "rnd"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps12(*this, tblgen_sat, "sat"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps13(*this, tblgen_dstTy, "dstTy"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps8(*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_NVVMOps10(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertBF16x2ToF8x2Op::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ConvertBF16x2ToF8x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); ::mlir::TypeAttr dstTyAttr; srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(dstTyAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (dstTyAttr) result.getOrAddProperties().dstTy = dstTyAttr; if (parser.parseRParen()) return ::mlir::failure(); result.addTypes(dstTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertBF16x2ToF8x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("dstTy"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getRndAttr(); if(attr && (attr == ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), FPRoundingMode::NONE))) elidedAttrs.push_back("rnd"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getSatAttr(); if(attr && (attr == ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE))) elidedAttrs.push_back("sat"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getDstTyAttr()); _odsPrinter << ")"; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertBF16x2ToF8x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertBF16x2ToF8x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertBF16x2ToS2F6x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertBF16x2ToS2F6x2OpGenericAdaptorBase::ConvertBF16x2ToS2F6x2OpGenericAdaptorBase(ConvertBF16x2ToS2F6x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ConvertBF16x2ToS2F6x2OpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::BoolAttr ConvertBF16x2ToS2F6x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertBF16x2ToS2F6x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } } // namespace detail ConvertBF16x2ToS2F6x2OpAdaptor::ConvertBF16x2ToS2F6x2OpAdaptor(ConvertBF16x2ToS2F6x2Op op) : ConvertBF16x2ToS2F6x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertBF16x2ToS2F6x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.bf16x2.to.s2f6x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair ConvertBF16x2ToS2F6x2Op::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 ConvertBF16x2ToS2F6x2Op::getScaleFactorMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult ConvertBF16x2ToS2F6x2Op::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.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertBF16x2ToS2F6x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertBF16x2ToS2F6x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relu.getAsOpaquePointer())); } std::optional ConvertBF16x2ToS2F6x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relu") return prop.relu; return std::nullopt; } void ConvertBF16x2ToS2F6x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertBF16x2ToS2F6x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relu) attrs.append("relu", prop.relu); } ::llvm::LogicalResult ConvertBF16x2ToS2F6x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertBF16x2ToS2F6x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); return ::mlir::success(); } void ConvertBF16x2ToS2F6x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relu); } bool ConvertBF16x2ToS2F6x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } void ConvertBF16x2ToS2F6x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertBF16x2ToS2F6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::BoolAttr relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.addTypes(dst); } ConvertBF16x2ToS2F6x2Op ConvertBF16x2ToS2F6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToS2F6x2Op ConvertBF16x2ToS2F6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(relu)); } void ConvertBF16x2ToS2F6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::BoolAttr relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); if (relu) { odsState.getOrAddProperties().relu = relu; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertBF16x2ToS2F6x2Op ConvertBF16x2ToS2F6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToS2F6x2Op ConvertBF16x2ToS2F6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(relu)); } void ConvertBF16x2ToS2F6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, bool relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.addTypes(dst); } ConvertBF16x2ToS2F6x2Op ConvertBF16x2ToS2F6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToS2F6x2Op ConvertBF16x2ToS2F6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, bool relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(relu)); } void ConvertBF16x2ToS2F6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, bool relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertBF16x2ToS2F6x2Op ConvertBF16x2ToS2F6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToS2F6x2Op ConvertBF16x2ToS2F6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, bool relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(relu)); } void ConvertBF16x2ToS2F6x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertBF16x2ToS2F6x2Op ConvertBF16x2ToS2F6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToS2F6x2Op ConvertBF16x2ToS2F6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertBF16x2ToS2F6x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertBF16x2ToS2F6x2Op ConvertBF16x2ToS2F6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertBF16x2ToS2F6x2Op ConvertBF16x2ToS2F6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertBF16x2ToS2F6x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertBF16x2ToS2F6x2Op::verifyInvariantsImpl() { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps8(*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_NVVMOps11(*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_NVVMOps10(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertBF16x2ToS2F6x2Op::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ConvertBF16x2ToS2F6x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> scaleFactorOperands; ::llvm::SMLoc scaleFactorOperandsLoc; (void)scaleFactorOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { scaleFactorOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); scaleFactorOperands.push_back(operand); } } } { 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(16); result.addTypes(dstTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); if (!scaleFactorOperands.empty()) { if (parser.resolveOperands(scaleFactorOperands, odsBuildableType0, scaleFactorOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void ConvertBF16x2ToS2F6x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); if (getScaleFactor()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getScaleFactor()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertBF16x2ToS2F6x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertBF16x2ToS2F6x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF16x2ToF4x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF16x2ToF4x2OpGenericAdaptorBase::ConvertF16x2ToF4x2OpGenericAdaptorBase(ConvertF16x2ToF4x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::BoolAttr ConvertF16x2ToF4x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF16x2ToF4x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF16x2ToF4x2OpGenericAdaptorBase::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } } // namespace detail ConvertF16x2ToF4x2OpAdaptor::ConvertF16x2ToF4x2OpAdaptor(ConvertF16x2ToF4x2Op op) : ConvertF16x2ToF4x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF16x2ToF4x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitError(loc, "'nvvm.convert.f16x2.to.f4x2' op requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f16x2.to.f4x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); if (tblgen_dstTy && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_dstTy))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))) && ((::llvm::isa<::mlir::Float4E2M1FNType>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))))) return emitError(loc, "'nvvm.convert.f16x2.to.f4x2' op attribute 'dstTy' failed to satisfy constraint: type attribute of f4E2M1FN type"); return ::mlir::success(); } ::llvm::LogicalResult ConvertF16x2ToF4x2Op::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.dstTy; auto attr = dict.get("dstTy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dstTy` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF16x2ToF4x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.dstTy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dstTy", propStorage)); } { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF16x2ToF4x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.dstTy.getAsOpaquePointer()), llvm::hash_value(prop.relu.getAsOpaquePointer())); } std::optional ConvertF16x2ToF4x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "dstTy") return prop.dstTy; if (name == "relu") return prop.relu; return std::nullopt; } void ConvertF16x2ToF4x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "dstTy") { prop.dstTy = ::llvm::dyn_cast_or_null>(value); return; } if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF16x2ToF4x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.dstTy) attrs.append("dstTy", prop.dstTy); if (prop.relu) attrs.append("relu", prop.relu); } ::llvm::LogicalResult ConvertF16x2ToF4x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getDstTyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps9(attr, "dstTy", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF16x2ToF4x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.dstTy))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF16x2ToF4x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.dstTy); writer.writeOptionalAttribute(prop.relu); } bool ConvertF16x2ToF4x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF16x2ToF4x2Op::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } void ConvertF16x2ToF4x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF16x2ToF4x2Op::setDstTy(::mlir::Type attrValue) { getProperties().dstTy = ::mlir::TypeAttr::get(attrValue); } void ConvertF16x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; odsState.addTypes(dst); } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertF16x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertF16x2ToF4x2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertF16x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertF16x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); odsState.addTypes(dst); } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertF16x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertF16x2ToF4x2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertF16x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertF16x2ToF4x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF16x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertF16x2ToF4x2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ConvertF16x2ToF4x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF16x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertF16x2ToF4x2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF4x2Op ConvertF16x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF16x2ToF4x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF16x2ToF4x2Op::verifyInvariantsImpl() { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitOpError("requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps9(*this, tblgen_dstTy, "dstTy"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps12(*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_NVVMOps9(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF16x2ToF4x2Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult ConvertF16x2ToF4x2Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(8); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ConvertF16x2ToF4x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); ::mlir::TypeAttr dstTyAttr; srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(dstTyAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (dstTyAttr) result.getOrAddProperties().dstTy = dstTyAttr; if (parser.parseRParen()) return ::mlir::failure(); result.addTypes(dstTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertF16x2ToF4x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("dstTy"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getDstTyAttr()); _odsPrinter << ")"; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF16x2ToF4x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF16x2ToF4x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF16x2ToF6x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF16x2ToF6x2OpGenericAdaptorBase::ConvertF16x2ToF6x2OpGenericAdaptorBase(ConvertF16x2ToF6x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::BoolAttr ConvertF16x2ToF6x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF16x2ToF6x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF16x2ToF6x2OpGenericAdaptorBase::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } } // namespace detail ConvertF16x2ToF6x2OpAdaptor::ConvertF16x2ToF6x2OpAdaptor(ConvertF16x2ToF6x2Op op) : ConvertF16x2ToF6x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF16x2ToF6x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitError(loc, "'nvvm.convert.f16x2.to.f6x2' op requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f16x2.to.f6x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); if (tblgen_dstTy && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_dstTy))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))) && (((::llvm::isa<::mlir::Float6E2M3FNType>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue())))))) return emitError(loc, "'nvvm.convert.f16x2.to.f6x2' op attribute 'dstTy' failed to satisfy constraint: type attribute of f6E2M3FN type or f6E3M2FN type"); return ::mlir::success(); } ::llvm::LogicalResult ConvertF16x2ToF6x2Op::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.dstTy; auto attr = dict.get("dstTy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dstTy` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF16x2ToF6x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.dstTy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dstTy", propStorage)); } { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF16x2ToF6x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.dstTy.getAsOpaquePointer()), llvm::hash_value(prop.relu.getAsOpaquePointer())); } std::optional ConvertF16x2ToF6x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "dstTy") return prop.dstTy; if (name == "relu") return prop.relu; return std::nullopt; } void ConvertF16x2ToF6x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "dstTy") { prop.dstTy = ::llvm::dyn_cast_or_null>(value); return; } if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF16x2ToF6x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.dstTy) attrs.append("dstTy", prop.dstTy); if (prop.relu) attrs.append("relu", prop.relu); } ::llvm::LogicalResult ConvertF16x2ToF6x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getDstTyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps10(attr, "dstTy", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF16x2ToF6x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.dstTy))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF16x2ToF6x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.dstTy); writer.writeOptionalAttribute(prop.relu); } bool ConvertF16x2ToF6x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF16x2ToF6x2Op::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } void ConvertF16x2ToF6x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF16x2ToF6x2Op::setDstTy(::mlir::Type attrValue) { getProperties().dstTy = ::mlir::TypeAttr::get(attrValue); } void ConvertF16x2ToF6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; odsState.addTypes(dst); } ConvertF16x2ToF6x2Op ConvertF16x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF6x2Op ConvertF16x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertF16x2ToF6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF16x2ToF6x2Op ConvertF16x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF6x2Op ConvertF16x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertF16x2ToF6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); odsState.addTypes(dst); } ConvertF16x2ToF6x2Op ConvertF16x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF6x2Op ConvertF16x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertF16x2ToF6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF16x2ToF6x2Op ConvertF16x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF6x2Op ConvertF16x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(relu), std::forward(dstTy)); } void ConvertF16x2ToF6x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF16x2ToF6x2Op ConvertF16x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF6x2Op ConvertF16x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF16x2ToF6x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF16x2ToF6x2Op ConvertF16x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF6x2Op ConvertF16x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF16x2ToF6x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF16x2ToF6x2Op::verifyInvariantsImpl() { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitOpError("requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps10(*this, tblgen_dstTy, "dstTy"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps12(*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_NVVMOps10(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF16x2ToF6x2Op::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ConvertF16x2ToF6x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); ::mlir::TypeAttr dstTyAttr; srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(dstTyAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (dstTyAttr) result.getOrAddProperties().dstTy = dstTyAttr; if (parser.parseRParen()) return ::mlir::failure(); result.addTypes(dstTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertF16x2ToF6x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("dstTy"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getDstTyAttr()); _odsPrinter << ")"; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF16x2ToF6x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF16x2ToF6x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF16x2ToF8x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF16x2ToF8x2OpGenericAdaptorBase::ConvertF16x2ToF8x2OpGenericAdaptorBase(ConvertF16x2ToF8x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::BoolAttr ConvertF16x2ToF8x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF16x2ToF8x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF16x2ToF8x2OpGenericAdaptorBase::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } } // namespace detail ConvertF16x2ToF8x2OpAdaptor::ConvertF16x2ToF8x2OpAdaptor(ConvertF16x2ToF8x2Op op) : ConvertF16x2ToF8x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF16x2ToF8x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitError(loc, "'nvvm.convert.f16x2.to.f8x2' op requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f16x2.to.f8x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); if (tblgen_dstTy && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_dstTy))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))) && ((true)))) return emitError(loc, "'nvvm.convert.f16x2.to.f8x2' op attribute 'dstTy' failed to satisfy constraint: any type attribute"); return ::mlir::success(); } ::llvm::LogicalResult ConvertF16x2ToF8x2Op::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.dstTy; auto attr = dict.get("dstTy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dstTy` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF16x2ToF8x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.dstTy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dstTy", propStorage)); } { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF16x2ToF8x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.dstTy.getAsOpaquePointer()), llvm::hash_value(prop.relu.getAsOpaquePointer())); } std::optional ConvertF16x2ToF8x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "dstTy") return prop.dstTy; if (name == "relu") return prop.relu; return std::nullopt; } void ConvertF16x2ToF8x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "dstTy") { prop.dstTy = ::llvm::dyn_cast_or_null>(value); return; } if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF16x2ToF8x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.dstTy) attrs.append("dstTy", prop.dstTy); if (prop.relu) attrs.append("relu", prop.relu); } ::llvm::LogicalResult ConvertF16x2ToF8x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getDstTyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps14(attr, "dstTy", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF16x2ToF8x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.dstTy))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF16x2ToF8x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.dstTy); writer.writeOptionalAttribute(prop.relu); } bool ConvertF16x2ToF8x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF16x2ToF8x2Op::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } void ConvertF16x2ToF8x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF16x2ToF8x2Op::setDstTy(::mlir::Type attrValue) { getProperties().dstTy = ::mlir::TypeAttr::get(attrValue); } void ConvertF16x2ToF8x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value a, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(a); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; odsState.addTypes(dst); } ConvertF16x2ToF8x2Op ConvertF16x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value a, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(a), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF8x2Op ConvertF16x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value a, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(a), std::forward(relu), std::forward(dstTy)); } void ConvertF16x2ToF8x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(a); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF16x2ToF8x2Op ConvertF16x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF8x2Op ConvertF16x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(relu), std::forward(dstTy)); } void ConvertF16x2ToF8x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value a, bool relu, ::mlir::Type dstTy) { odsState.addOperands(a); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); odsState.addTypes(dst); } ConvertF16x2ToF8x2Op ConvertF16x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value a, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(a), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF8x2Op ConvertF16x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value a, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(a), std::forward(relu), std::forward(dstTy)); } void ConvertF16x2ToF8x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, bool relu, ::mlir::Type dstTy) { odsState.addOperands(a); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF16x2ToF8x2Op ConvertF16x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF8x2Op ConvertF16x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(relu), std::forward(dstTy)); } void ConvertF16x2ToF8x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF16x2ToF8x2Op ConvertF16x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF8x2Op ConvertF16x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF16x2ToF8x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF16x2ToF8x2Op ConvertF16x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF16x2ToF8x2Op ConvertF16x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF16x2ToF8x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF16x2ToF8x2Op::verifyInvariantsImpl() { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitOpError("requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps14(*this, tblgen_dstTy, "dstTy"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps12(*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_NVVMOps10(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF16x2ToF8x2Op::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ConvertF16x2ToF8x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand aRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(&aRawOperand, 1); ::llvm::SMLoc aOperandsLoc; (void)aOperandsLoc; ::mlir::Type aRawType{}; ::llvm::ArrayRef<::mlir::Type> aTypes(&aRawType, 1); ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); ::mlir::TypeAttr dstTyAttr; aOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(aRawOperand)) 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); aRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(dstTyAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (dstTyAttr) result.getOrAddProperties().dstTy = dstTyAttr; if (parser.parseRParen()) return ::mlir::failure(); result.addTypes(dstTypes); if (parser.resolveOperands(aOperands, aTypes, aOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertF16x2ToF8x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getA(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("dstTy"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getA().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getDstTyAttr()); _odsPrinter << ")"; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF16x2ToF8x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF16x2ToF8x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF32x2ToBF16x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF32x2ToBF16x2OpGenericAdaptorBase::ConvertF32x2ToBF16x2OpGenericAdaptorBase(ConvertF32x2ToBF16x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ConvertF32x2ToBF16x2OpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::NVVM::FPRoundingModeAttr ConvertF32x2ToBF16x2OpGenericAdaptorBase::getRndAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::FPRoundingModeAttr>(getProperties().rnd); return attr; } ::mlir::NVVM::FPRoundingMode ConvertF32x2ToBF16x2OpGenericAdaptorBase::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::NVVM::SaturationModeAttr ConvertF32x2ToBF16x2OpGenericAdaptorBase::getSatAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::SaturationModeAttr>(getProperties().sat); return attr; } ::mlir::NVVM::SaturationMode ConvertF32x2ToBF16x2OpGenericAdaptorBase::getSat() { auto attr = getSatAttr(); return attr.getValue(); } ::mlir::BoolAttr ConvertF32x2ToBF16x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF32x2ToBF16x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } } // namespace detail ConvertF32x2ToBF16x2OpAdaptor::ConvertF32x2ToBF16x2OpAdaptor(ConvertF32x2ToBF16x2Op op) : ConvertF32x2ToBF16x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF32x2ToBF16x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (tblgen_rnd && !((::llvm::isa<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd)))) return emitError(loc, "'nvvm.convert.f32x2.to.bf16x2' op attribute 'rnd' failed to satisfy constraint: NVVM FPRoundingMode kind"); if (tblgen_sat && !((::llvm::isa<::mlir::NVVM::SaturationModeAttr>(tblgen_sat)))) return emitError(loc, "'nvvm.convert.f32x2.to.bf16x2' op attribute 'sat' failed to satisfy constraint: Describes the saturation mode"); if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f32x2.to.bf16x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair ConvertF32x2ToBF16x2Op::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange ConvertF32x2ToBF16x2Op::getRandomBitsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult ConvertF32x2ToBF16x2Op::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.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.rnd; auto attr = dict.get("rnd"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `rnd` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sat; auto attr = dict.get("sat"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sat` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF32x2ToBF16x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } { const auto &propStorage = prop.rnd; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("rnd", propStorage)); } { const auto &propStorage = prop.sat; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sat", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF32x2ToBF16x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relu.getAsOpaquePointer()), llvm::hash_value(prop.rnd.getAsOpaquePointer()), llvm::hash_value(prop.sat.getAsOpaquePointer())); } std::optional ConvertF32x2ToBF16x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relu") return prop.relu; if (name == "rnd") return prop.rnd; if (name == "sat") return prop.sat; return std::nullopt; } void ConvertF32x2ToBF16x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } if (name == "rnd") { prop.rnd = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sat") { prop.sat = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF32x2ToBF16x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relu) attrs.append("relu", prop.relu); if (prop.rnd) attrs.append("rnd", prop.rnd); if (prop.sat) attrs.append("sat", prop.sat); } ::llvm::LogicalResult ConvertF32x2ToBF16x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRndAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps11(attr, "rnd", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSatAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps12(attr, "sat", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x2ToBF16x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.rnd))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.sat))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF32x2ToBF16x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relu); writer.writeOptionalAttribute(prop.rnd); writer.writeOptionalAttribute(prop.sat); } ::mlir::NVVM::FPRoundingMode ConvertF32x2ToBF16x2Op::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::NVVM::SaturationMode ConvertF32x2ToBF16x2Op::getSat() { auto attr = getSatAttr(); return attr.getValue(); } bool ConvertF32x2ToBF16x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } void ConvertF32x2ToBF16x2Op::setRnd(::mlir::NVVM::FPRoundingMode attrValue) { getProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ConvertF32x2ToBF16x2Op::setSat(::mlir::NVVM::SaturationMode attrValue) { getProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ConvertF32x2ToBF16x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF32x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { odsState.addOperands(src_hi); odsState.addOperands(src_lo); if (random_bits) odsState.addOperands(random_bits); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.addTypes(dst); } ConvertF32x2ToBF16x2Op ConvertF32x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src_hi), std::forward(src_lo), std::forward(random_bits), std::forward(rnd), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToBF16x2Op ConvertF32x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src_hi), std::forward(src_lo), std::forward(random_bits), std::forward(rnd), std::forward(sat), std::forward(relu)); } void ConvertF32x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { odsState.addOperands(src_hi); odsState.addOperands(src_lo); if (random_bits) odsState.addOperands(random_bits); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x2ToBF16x2Op ConvertF32x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src_hi), std::forward(src_lo), std::forward(random_bits), std::forward(rnd), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToBF16x2Op ConvertF32x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src_hi), std::forward(src_lo), std::forward(random_bits), std::forward(rnd), std::forward(sat), std::forward(relu)); } void ConvertF32x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { odsState.addOperands(src_hi); odsState.addOperands(src_lo); if (random_bits) odsState.addOperands(random_bits); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.addTypes(dst); } ConvertF32x2ToBF16x2Op ConvertF32x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src_hi), std::forward(src_lo), std::forward(random_bits), std::forward(rnd), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToBF16x2Op ConvertF32x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src_hi), std::forward(src_lo), std::forward(random_bits), std::forward(rnd), std::forward(sat), std::forward(relu)); } void ConvertF32x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { odsState.addOperands(src_hi); odsState.addOperands(src_lo); if (random_bits) odsState.addOperands(random_bits); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x2ToBF16x2Op ConvertF32x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src_hi), std::forward(src_lo), std::forward(random_bits), std::forward(rnd), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToBF16x2Op ConvertF32x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src_hi), std::forward(src_lo), std::forward(random_bits), std::forward(rnd), std::forward(sat), std::forward(relu)); } void ConvertF32x2ToBF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF32x2ToBF16x2Op ConvertF32x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToBF16x2Op ConvertF32x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF32x2ToBF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF32x2ToBF16x2Op ConvertF32x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToBF16x2Op ConvertF32x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF32x2ToBF16x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.rnd) properties.rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), FPRoundingMode::NONE); if (!properties.sat) properties.sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF32x2ToBF16x2Op::verifyInvariantsImpl() { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps11(*this, tblgen_rnd, "rnd"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps12(*this, tblgen_sat, "sat"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*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_NVVMOps2(*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_NVVMOps8(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x2ToBF16x2Op::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ConvertF32x2ToBF16x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand src_hiRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> src_hiOperands(&src_hiRawOperand, 1); ::llvm::SMLoc src_hiOperandsLoc; (void)src_hiOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand src_loRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> src_loOperands(&src_loRawOperand, 1); ::llvm::SMLoc src_loOperandsLoc; (void)src_loOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> random_bitsOperands; ::llvm::SMLoc random_bitsOperandsLoc; (void)random_bitsOperandsLoc; ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); src_hiOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(src_hiRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); src_loOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(src_loRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { random_bitsOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); random_bitsOperands.push_back(operand); } } } { 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getF32Type(); ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(32); result.addTypes(dstTypes); if (parser.resolveOperands(src_hiOperands, odsBuildableType0, src_hiOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(src_loOperands, odsBuildableType0, src_loOperandsLoc, result.operands)) return ::mlir::failure(); if (!random_bitsOperands.empty()) { if (parser.resolveOperands(random_bitsOperands, odsBuildableType1, random_bitsOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void ConvertF32x2ToBF16x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrcHi(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSrcLo(); if (getRandomBits()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getRandomBits()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getRndAttr(); if(attr && (attr == ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), FPRoundingMode::NONE))) elidedAttrs.push_back("rnd"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getSatAttr(); if(attr && (attr == ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE))) elidedAttrs.push_back("sat"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ConvertF32x2ToBF16x2Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF32x2ToBF16x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF32x2ToBF16x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF32x2ToF16x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF32x2ToF16x2OpGenericAdaptorBase::ConvertF32x2ToF16x2OpGenericAdaptorBase(ConvertF32x2ToF16x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ConvertF32x2ToF16x2OpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::NVVM::FPRoundingModeAttr ConvertF32x2ToF16x2OpGenericAdaptorBase::getRndAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::FPRoundingModeAttr>(getProperties().rnd); return attr; } ::mlir::NVVM::FPRoundingMode ConvertF32x2ToF16x2OpGenericAdaptorBase::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::NVVM::SaturationModeAttr ConvertF32x2ToF16x2OpGenericAdaptorBase::getSatAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::SaturationModeAttr>(getProperties().sat); return attr; } ::mlir::NVVM::SaturationMode ConvertF32x2ToF16x2OpGenericAdaptorBase::getSat() { auto attr = getSatAttr(); return attr.getValue(); } ::mlir::BoolAttr ConvertF32x2ToF16x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF32x2ToF16x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } } // namespace detail ConvertF32x2ToF16x2OpAdaptor::ConvertF32x2ToF16x2OpAdaptor(ConvertF32x2ToF16x2Op op) : ConvertF32x2ToF16x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF32x2ToF16x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (tblgen_rnd && !((::llvm::isa<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd)))) return emitError(loc, "'nvvm.convert.f32x2.to.f16x2' op attribute 'rnd' failed to satisfy constraint: NVVM FPRoundingMode kind"); if (tblgen_sat && !((::llvm::isa<::mlir::NVVM::SaturationModeAttr>(tblgen_sat)))) return emitError(loc, "'nvvm.convert.f32x2.to.f16x2' op attribute 'sat' failed to satisfy constraint: Describes the saturation mode"); if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f32x2.to.f16x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair ConvertF32x2ToF16x2Op::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange ConvertF32x2ToF16x2Op::getRandomBitsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult ConvertF32x2ToF16x2Op::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.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.rnd; auto attr = dict.get("rnd"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `rnd` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sat; auto attr = dict.get("sat"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sat` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF32x2ToF16x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } { const auto &propStorage = prop.rnd; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("rnd", propStorage)); } { const auto &propStorage = prop.sat; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sat", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF32x2ToF16x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relu.getAsOpaquePointer()), llvm::hash_value(prop.rnd.getAsOpaquePointer()), llvm::hash_value(prop.sat.getAsOpaquePointer())); } std::optional ConvertF32x2ToF16x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relu") return prop.relu; if (name == "rnd") return prop.rnd; if (name == "sat") return prop.sat; return std::nullopt; } void ConvertF32x2ToF16x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } if (name == "rnd") { prop.rnd = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sat") { prop.sat = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF32x2ToF16x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relu) attrs.append("relu", prop.relu); if (prop.rnd) attrs.append("rnd", prop.rnd); if (prop.sat) attrs.append("sat", prop.sat); } ::llvm::LogicalResult ConvertF32x2ToF16x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRndAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps11(attr, "rnd", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSatAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps12(attr, "sat", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x2ToF16x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.rnd))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.sat))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF32x2ToF16x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relu); writer.writeOptionalAttribute(prop.rnd); writer.writeOptionalAttribute(prop.sat); } ::mlir::NVVM::FPRoundingMode ConvertF32x2ToF16x2Op::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::NVVM::SaturationMode ConvertF32x2ToF16x2Op::getSat() { auto attr = getSatAttr(); return attr.getValue(); } bool ConvertF32x2ToF16x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } void ConvertF32x2ToF16x2Op::setRnd(::mlir::NVVM::FPRoundingMode attrValue) { getProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ConvertF32x2ToF16x2Op::setSat(::mlir::NVVM::SaturationMode attrValue) { getProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ConvertF32x2ToF16x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF32x2ToF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { odsState.addOperands(src_hi); odsState.addOperands(src_lo); if (random_bits) odsState.addOperands(random_bits); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.addTypes(dst); } ConvertF32x2ToF16x2Op ConvertF32x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src_hi), std::forward(src_lo), std::forward(random_bits), std::forward(rnd), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF16x2Op ConvertF32x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src_hi), std::forward(src_lo), std::forward(random_bits), std::forward(rnd), std::forward(sat), std::forward(relu)); } void ConvertF32x2ToF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { odsState.addOperands(src_hi); odsState.addOperands(src_lo); if (random_bits) odsState.addOperands(random_bits); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x2ToF16x2Op ConvertF32x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src_hi), std::forward(src_lo), std::forward(random_bits), std::forward(rnd), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF16x2Op ConvertF32x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src_hi), std::forward(src_lo), std::forward(random_bits), std::forward(rnd), std::forward(sat), std::forward(relu)); } void ConvertF32x2ToF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { odsState.addOperands(src_hi); odsState.addOperands(src_lo); if (random_bits) odsState.addOperands(random_bits); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.addTypes(dst); } ConvertF32x2ToF16x2Op ConvertF32x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src_hi), std::forward(src_lo), std::forward(random_bits), std::forward(rnd), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF16x2Op ConvertF32x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src_hi), std::forward(src_lo), std::forward(random_bits), std::forward(rnd), std::forward(sat), std::forward(relu)); } void ConvertF32x2ToF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { odsState.addOperands(src_hi); odsState.addOperands(src_lo); if (random_bits) odsState.addOperands(random_bits); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x2ToF16x2Op ConvertF32x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src_hi), std::forward(src_lo), std::forward(random_bits), std::forward(rnd), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF16x2Op ConvertF32x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src_hi, ::mlir::Value src_lo, /*optional*/::mlir::Value random_bits, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src_hi), std::forward(src_lo), std::forward(random_bits), std::forward(rnd), std::forward(sat), std::forward(relu)); } void ConvertF32x2ToF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF32x2ToF16x2Op ConvertF32x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF16x2Op ConvertF32x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF32x2ToF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF32x2ToF16x2Op ConvertF32x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF16x2Op ConvertF32x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF32x2ToF16x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.rnd) properties.rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), FPRoundingMode::NONE); if (!properties.sat) properties.sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF32x2ToF16x2Op::verifyInvariantsImpl() { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps11(*this, tblgen_rnd, "rnd"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps12(*this, tblgen_sat, "sat"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*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_NVVMOps2(*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_NVVMOps12(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x2ToF16x2Op::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ConvertF32x2ToF16x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand src_hiRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> src_hiOperands(&src_hiRawOperand, 1); ::llvm::SMLoc src_hiOperandsLoc; (void)src_hiOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand src_loRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> src_loOperands(&src_loRawOperand, 1); ::llvm::SMLoc src_loOperandsLoc; (void)src_loOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> random_bitsOperands; ::llvm::SMLoc random_bitsOperandsLoc; (void)random_bitsOperandsLoc; ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); src_hiOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(src_hiRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); src_loOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(src_loRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { random_bitsOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); random_bitsOperands.push_back(operand); } } } { 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getF32Type(); ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(32); result.addTypes(dstTypes); if (parser.resolveOperands(src_hiOperands, odsBuildableType0, src_hiOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(src_loOperands, odsBuildableType0, src_loOperandsLoc, result.operands)) return ::mlir::failure(); if (!random_bitsOperands.empty()) { if (parser.resolveOperands(random_bitsOperands, odsBuildableType1, random_bitsOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void ConvertF32x2ToF16x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrcHi(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSrcLo(); if (getRandomBits()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getRandomBits()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getRndAttr(); if(attr && (attr == ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), FPRoundingMode::NONE))) elidedAttrs.push_back("rnd"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getSatAttr(); if(attr && (attr == ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE))) elidedAttrs.push_back("sat"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ConvertF32x2ToF16x2Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF32x2ToF16x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF32x2ToF16x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF32x2ToF4x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF32x2ToF4x2OpGenericAdaptorBase::ConvertF32x2ToF4x2OpGenericAdaptorBase(ConvertF32x2ToF4x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::BoolAttr ConvertF32x2ToF4x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF32x2ToF4x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF32x2ToF4x2OpGenericAdaptorBase::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } } // namespace detail ConvertF32x2ToF4x2OpAdaptor::ConvertF32x2ToF4x2OpAdaptor(ConvertF32x2ToF4x2Op op) : ConvertF32x2ToF4x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF32x2ToF4x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitError(loc, "'nvvm.convert.f32x2.to.f4x2' op requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f32x2.to.f4x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); if (tblgen_dstTy && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_dstTy))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))) && ((true)))) return emitError(loc, "'nvvm.convert.f32x2.to.f4x2' op attribute 'dstTy' failed to satisfy constraint: any type attribute"); return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x2ToF4x2Op::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.dstTy; auto attr = dict.get("dstTy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dstTy` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF32x2ToF4x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.dstTy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dstTy", propStorage)); } { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF32x2ToF4x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.dstTy.getAsOpaquePointer()), llvm::hash_value(prop.relu.getAsOpaquePointer())); } std::optional ConvertF32x2ToF4x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "dstTy") return prop.dstTy; if (name == "relu") return prop.relu; return std::nullopt; } void ConvertF32x2ToF4x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "dstTy") { prop.dstTy = ::llvm::dyn_cast_or_null>(value); return; } if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF32x2ToF4x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.dstTy) attrs.append("dstTy", prop.dstTy); if (prop.relu) attrs.append("relu", prop.relu); } ::llvm::LogicalResult ConvertF32x2ToF4x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getDstTyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps14(attr, "dstTy", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x2ToF4x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.dstTy))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF32x2ToF4x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.dstTy); writer.writeOptionalAttribute(prop.relu); } bool ConvertF32x2ToF4x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF32x2ToF4x2Op::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } void ConvertF32x2ToF4x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF32x2ToF4x2Op::setDstTy(::mlir::Type attrValue) { getProperties().dstTy = ::mlir::TypeAttr::get(attrValue); } void ConvertF32x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(a); odsState.addOperands(b); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; odsState.addTypes(dst); } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); } void ConvertF32x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(a); odsState.addOperands(b); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertF32x2ToF4x2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); } void ConvertF32x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(a); odsState.addOperands(b); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); } void ConvertF32x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, bool relu, ::mlir::Type dstTy) { odsState.addOperands(a); odsState.addOperands(b); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); odsState.addTypes(dst); } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); } void ConvertF32x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b, bool relu, ::mlir::Type dstTy) { odsState.addOperands(a); odsState.addOperands(b); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertF32x2ToF4x2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value a, ::mlir::Value b, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value a, ::mlir::Value b, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); } void ConvertF32x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, bool relu, ::mlir::Type dstTy) { odsState.addOperands(a); odsState.addOperands(b); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); } void ConvertF32x2ToF4x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF32x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertF32x2ToF4x2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ConvertF32x2ToF4x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF32x2ToF4x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertF32x2ToF4x2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF4x2Op ConvertF32x2ToF4x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF32x2ToF4x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF32x2ToF4x2Op::verifyInvariantsImpl() { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitOpError("requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps14(*this, tblgen_dstTy, "dstTy"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*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_NVVMOps9(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x2ToF4x2Op::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ConvertF32x2ToF4x2Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(8); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ConvertF32x2ToF4x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand aRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(&aRawOperand, 1); ::llvm::SMLoc aOperandsLoc; (void)aOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand bRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> bOperands(&bRawOperand, 1); ::llvm::SMLoc bOperandsLoc; (void)bOperandsLoc; ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); ::mlir::TypeAttr dstTyAttr; aOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(aRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); bOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(bRawOperand)) 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(); dstRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(dstTyAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (dstTyAttr) result.getOrAddProperties().dstTy = dstTyAttr; if (parser.parseRParen()) return ::mlir::failure(); ::mlir::Type odsBuildableType0 = parser.getBuilder().getF32Type(); result.addTypes(dstTypes); if (parser.resolveOperands(aOperands, odsBuildableType0, aOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(bOperands, odsBuildableType0, bOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertF32x2ToF4x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getA(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getB(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("dstTy"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getDstTyAttr()); _odsPrinter << ")"; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF32x2ToF4x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF32x2ToF4x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF32x2ToF6x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF32x2ToF6x2OpGenericAdaptorBase::ConvertF32x2ToF6x2OpGenericAdaptorBase(ConvertF32x2ToF6x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::BoolAttr ConvertF32x2ToF6x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF32x2ToF6x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF32x2ToF6x2OpGenericAdaptorBase::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } } // namespace detail ConvertF32x2ToF6x2OpAdaptor::ConvertF32x2ToF6x2OpAdaptor(ConvertF32x2ToF6x2Op op) : ConvertF32x2ToF6x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF32x2ToF6x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitError(loc, "'nvvm.convert.f32x2.to.f6x2' op requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f32x2.to.f6x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); if (tblgen_dstTy && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_dstTy))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))) && ((true)))) return emitError(loc, "'nvvm.convert.f32x2.to.f6x2' op attribute 'dstTy' failed to satisfy constraint: any type attribute"); return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x2ToF6x2Op::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.dstTy; auto attr = dict.get("dstTy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dstTy` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF32x2ToF6x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.dstTy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dstTy", propStorage)); } { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF32x2ToF6x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.dstTy.getAsOpaquePointer()), llvm::hash_value(prop.relu.getAsOpaquePointer())); } std::optional ConvertF32x2ToF6x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "dstTy") return prop.dstTy; if (name == "relu") return prop.relu; return std::nullopt; } void ConvertF32x2ToF6x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "dstTy") { prop.dstTy = ::llvm::dyn_cast_or_null>(value); return; } if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF32x2ToF6x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.dstTy) attrs.append("dstTy", prop.dstTy); if (prop.relu) attrs.append("relu", prop.relu); } ::llvm::LogicalResult ConvertF32x2ToF6x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getDstTyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps14(attr, "dstTy", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x2ToF6x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.dstTy))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF32x2ToF6x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.dstTy); writer.writeOptionalAttribute(prop.relu); } bool ConvertF32x2ToF6x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF32x2ToF6x2Op::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } void ConvertF32x2ToF6x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF32x2ToF6x2Op::setDstTy(::mlir::Type attrValue) { getProperties().dstTy = ::mlir::TypeAttr::get(attrValue); } void ConvertF32x2ToF6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(a); odsState.addOperands(b); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; odsState.addTypes(dst); } ConvertF32x2ToF6x2Op ConvertF32x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF6x2Op ConvertF32x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); } void ConvertF32x2ToF6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(a); odsState.addOperands(b); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x2ToF6x2Op ConvertF32x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF6x2Op ConvertF32x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); } void ConvertF32x2ToF6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, bool relu, ::mlir::Type dstTy) { odsState.addOperands(a); odsState.addOperands(b); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); odsState.addTypes(dst); } ConvertF32x2ToF6x2Op ConvertF32x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF6x2Op ConvertF32x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); } void ConvertF32x2ToF6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, bool relu, ::mlir::Type dstTy) { odsState.addOperands(a); odsState.addOperands(b); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x2ToF6x2Op ConvertF32x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF6x2Op ConvertF32x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(relu), std::forward(dstTy)); } void ConvertF32x2ToF6x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF32x2ToF6x2Op ConvertF32x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF6x2Op ConvertF32x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF32x2ToF6x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF32x2ToF6x2Op ConvertF32x2ToF6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF6x2Op ConvertF32x2ToF6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF32x2ToF6x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF32x2ToF6x2Op::verifyInvariantsImpl() { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitOpError("requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps14(*this, tblgen_dstTy, "dstTy"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*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_NVVMOps10(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x2ToF6x2Op::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ConvertF32x2ToF6x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand aRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(&aRawOperand, 1); ::llvm::SMLoc aOperandsLoc; (void)aOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand bRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> bOperands(&bRawOperand, 1); ::llvm::SMLoc bOperandsLoc; (void)bOperandsLoc; ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); ::mlir::TypeAttr dstTyAttr; aOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(aRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); bOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(bRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(dstTyAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (dstTyAttr) result.getOrAddProperties().dstTy = dstTyAttr; if (parser.parseRParen()) return ::mlir::failure(); ::mlir::Type odsBuildableType0 = parser.getBuilder().getF32Type(); result.addTypes(dstTypes); if (parser.resolveOperands(aOperands, odsBuildableType0, aOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(bOperands, odsBuildableType0, bOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertF32x2ToF6x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getA(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getB(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("dstTy"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getDstTyAttr()); _odsPrinter << ")"; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF32x2ToF6x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF32x2ToF6x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF32x2ToF8x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF32x2ToF8x2OpGenericAdaptorBase::ConvertF32x2ToF8x2OpGenericAdaptorBase(ConvertF32x2ToF8x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::FPRoundingModeAttr ConvertF32x2ToF8x2OpGenericAdaptorBase::getRndAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::FPRoundingModeAttr>(getProperties().rnd); return attr; } ::mlir::NVVM::FPRoundingMode ConvertF32x2ToF8x2OpGenericAdaptorBase::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::NVVM::SaturationModeAttr ConvertF32x2ToF8x2OpGenericAdaptorBase::getSatAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::SaturationModeAttr>(getProperties().sat); return attr; } ::mlir::NVVM::SaturationMode ConvertF32x2ToF8x2OpGenericAdaptorBase::getSat() { auto attr = getSatAttr(); return attr.getValue(); } ::mlir::BoolAttr ConvertF32x2ToF8x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF32x2ToF8x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF32x2ToF8x2OpGenericAdaptorBase::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } } // namespace detail ConvertF32x2ToF8x2OpAdaptor::ConvertF32x2ToF8x2OpAdaptor(ConvertF32x2ToF8x2Op op) : ConvertF32x2ToF8x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF32x2ToF8x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitError(loc, "'nvvm.convert.f32x2.to.f8x2' op requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (tblgen_rnd && !((::llvm::isa<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd)))) return emitError(loc, "'nvvm.convert.f32x2.to.f8x2' op attribute 'rnd' failed to satisfy constraint: NVVM FPRoundingMode kind"); if (tblgen_sat && !((::llvm::isa<::mlir::NVVM::SaturationModeAttr>(tblgen_sat)))) return emitError(loc, "'nvvm.convert.f32x2.to.f8x2' op attribute 'sat' failed to satisfy constraint: Describes the saturation mode"); if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f32x2.to.f8x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); if (tblgen_dstTy && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_dstTy))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))) && ((true)))) return emitError(loc, "'nvvm.convert.f32x2.to.f8x2' op attribute 'dstTy' failed to satisfy constraint: any type attribute"); return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x2ToF8x2Op::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.dstTy; auto attr = dict.get("dstTy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dstTy` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.rnd; auto attr = dict.get("rnd"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `rnd` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sat; auto attr = dict.get("sat"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sat` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF32x2ToF8x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.dstTy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dstTy", propStorage)); } { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } { const auto &propStorage = prop.rnd; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("rnd", propStorage)); } { const auto &propStorage = prop.sat; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sat", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF32x2ToF8x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.dstTy.getAsOpaquePointer()), llvm::hash_value(prop.relu.getAsOpaquePointer()), llvm::hash_value(prop.rnd.getAsOpaquePointer()), llvm::hash_value(prop.sat.getAsOpaquePointer())); } std::optional ConvertF32x2ToF8x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "dstTy") return prop.dstTy; if (name == "relu") return prop.relu; if (name == "rnd") return prop.rnd; if (name == "sat") return prop.sat; return std::nullopt; } void ConvertF32x2ToF8x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "dstTy") { prop.dstTy = ::llvm::dyn_cast_or_null>(value); return; } if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } if (name == "rnd") { prop.rnd = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sat") { prop.sat = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF32x2ToF8x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.dstTy) attrs.append("dstTy", prop.dstTy); if (prop.relu) attrs.append("relu", prop.relu); if (prop.rnd) attrs.append("rnd", prop.rnd); if (prop.sat) attrs.append("sat", prop.sat); } ::llvm::LogicalResult ConvertF32x2ToF8x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getDstTyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps14(attr, "dstTy", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRndAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps11(attr, "rnd", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSatAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps12(attr, "sat", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x2ToF8x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.dstTy))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.rnd))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.sat))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF32x2ToF8x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.dstTy); writer.writeOptionalAttribute(prop.relu); writer.writeOptionalAttribute(prop.rnd); writer.writeOptionalAttribute(prop.sat); } ::mlir::NVVM::FPRoundingMode ConvertF32x2ToF8x2Op::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::NVVM::SaturationMode ConvertF32x2ToF8x2Op::getSat() { auto attr = getSatAttr(); return attr.getValue(); } bool ConvertF32x2ToF8x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF32x2ToF8x2Op::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } void ConvertF32x2ToF8x2Op::setRnd(::mlir::NVVM::FPRoundingMode attrValue) { getProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ConvertF32x2ToF8x2Op::setSat(::mlir::NVVM::SaturationMode attrValue) { getProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ConvertF32x2ToF8x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF32x2ToF8x2Op::setDstTy(::mlir::Type attrValue) { getProperties().dstTy = ::mlir::TypeAttr::get(attrValue); } void ConvertF32x2ToF8x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(a); odsState.addOperands(b); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; odsState.addTypes(dst); } ConvertF32x2ToF8x2Op ConvertF32x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(a), std::forward(b), std::forward(rnd), std::forward(sat), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF8x2Op ConvertF32x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(a), std::forward(b), std::forward(rnd), std::forward(sat), std::forward(relu), std::forward(dstTy)); } void ConvertF32x2ToF8x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(a); odsState.addOperands(b); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x2ToF8x2Op ConvertF32x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(rnd), std::forward(sat), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF8x2Op ConvertF32x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(rnd), std::forward(sat), std::forward(relu), std::forward(dstTy)); } void ConvertF32x2ToF8x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu, ::mlir::Type dstTy) { odsState.addOperands(a); odsState.addOperands(b); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); odsState.addTypes(dst); } ConvertF32x2ToF8x2Op ConvertF32x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(a), std::forward(b), std::forward(rnd), std::forward(sat), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF8x2Op ConvertF32x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(a), std::forward(b), std::forward(rnd), std::forward(sat), std::forward(relu), std::forward(dstTy)); } void ConvertF32x2ToF8x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu, ::mlir::Type dstTy) { odsState.addOperands(a); odsState.addOperands(b); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x2ToF8x2Op ConvertF32x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(rnd), std::forward(sat), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF8x2Op ConvertF32x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(rnd), std::forward(sat), std::forward(relu), std::forward(dstTy)); } void ConvertF32x2ToF8x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF32x2ToF8x2Op ConvertF32x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF8x2Op ConvertF32x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF32x2ToF8x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF32x2ToF8x2Op ConvertF32x2ToF8x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToF8x2Op ConvertF32x2ToF8x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF32x2ToF8x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.rnd) properties.rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), FPRoundingMode::NONE); if (!properties.sat) properties.sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF32x2ToF8x2Op::verifyInvariantsImpl() { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitOpError("requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps11(*this, tblgen_rnd, "rnd"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps12(*this, tblgen_sat, "sat"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps14(*this, tblgen_dstTy, "dstTy"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*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_NVVMOps10(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x2ToF8x2Op::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ConvertF32x2ToF8x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand aRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(&aRawOperand, 1); ::llvm::SMLoc aOperandsLoc; (void)aOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand bRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> bOperands(&bRawOperand, 1); ::llvm::SMLoc bOperandsLoc; (void)bOperandsLoc; ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); ::mlir::TypeAttr dstTyAttr; aOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(aRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); bOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(bRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(dstTyAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (dstTyAttr) result.getOrAddProperties().dstTy = dstTyAttr; if (parser.parseRParen()) return ::mlir::failure(); ::mlir::Type odsBuildableType0 = parser.getBuilder().getF32Type(); result.addTypes(dstTypes); if (parser.resolveOperands(aOperands, odsBuildableType0, aOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(bOperands, odsBuildableType0, bOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertF32x2ToF8x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getA(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getB(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("dstTy"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getRndAttr(); if(attr && (attr == ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), FPRoundingMode::NONE))) elidedAttrs.push_back("rnd"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getSatAttr(); if(attr && (attr == ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE))) elidedAttrs.push_back("sat"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getDstTyAttr()); _odsPrinter << ")"; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF32x2ToF8x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF32x2ToF8x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF32x2ToS2F6x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF32x2ToS2F6x2OpGenericAdaptorBase::ConvertF32x2ToS2F6x2OpGenericAdaptorBase(ConvertF32x2ToS2F6x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ConvertF32x2ToS2F6x2OpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::BoolAttr ConvertF32x2ToS2F6x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF32x2ToS2F6x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } } // namespace detail ConvertF32x2ToS2F6x2OpAdaptor::ConvertF32x2ToS2F6x2OpAdaptor(ConvertF32x2ToS2F6x2Op op) : ConvertF32x2ToS2F6x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF32x2ToS2F6x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f32x2.to.s2f6x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair ConvertF32x2ToS2F6x2Op::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange ConvertF32x2ToS2F6x2Op::getScaleFactorMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult ConvertF32x2ToS2F6x2Op::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.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF32x2ToS2F6x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF32x2ToS2F6x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relu.getAsOpaquePointer())); } std::optional ConvertF32x2ToS2F6x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relu") return prop.relu; return std::nullopt; } void ConvertF32x2ToS2F6x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF32x2ToS2F6x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relu) attrs.append("relu", prop.relu); } ::llvm::LogicalResult ConvertF32x2ToS2F6x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x2ToS2F6x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF32x2ToS2F6x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relu); } bool ConvertF32x2ToS2F6x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } void ConvertF32x2ToS2F6x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF32x2ToS2F6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, /*optional*/::mlir::Value scaleFactor, ::mlir::BoolAttr relu) { odsState.addOperands(a); odsState.addOperands(b); if (scaleFactor) odsState.addOperands(scaleFactor); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.addTypes(dst); } ConvertF32x2ToS2F6x2Op ConvertF32x2ToS2F6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, /*optional*/::mlir::Value scaleFactor, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(a), std::forward(b), std::forward(scaleFactor), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToS2F6x2Op ConvertF32x2ToS2F6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, /*optional*/::mlir::Value scaleFactor, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(a), std::forward(b), std::forward(scaleFactor), std::forward(relu)); } void ConvertF32x2ToS2F6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, /*optional*/::mlir::Value scaleFactor, ::mlir::BoolAttr relu) { odsState.addOperands(a); odsState.addOperands(b); if (scaleFactor) odsState.addOperands(scaleFactor); if (relu) { odsState.getOrAddProperties().relu = relu; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x2ToS2F6x2Op ConvertF32x2ToS2F6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, /*optional*/::mlir::Value scaleFactor, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(scaleFactor), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToS2F6x2Op ConvertF32x2ToS2F6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, /*optional*/::mlir::Value scaleFactor, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(scaleFactor), std::forward(relu)); } void ConvertF32x2ToS2F6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, /*optional*/::mlir::Value scaleFactor, bool relu) { odsState.addOperands(a); odsState.addOperands(b); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.addTypes(dst); } ConvertF32x2ToS2F6x2Op ConvertF32x2ToS2F6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, /*optional*/::mlir::Value scaleFactor, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(a), std::forward(b), std::forward(scaleFactor), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToS2F6x2Op ConvertF32x2ToS2F6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value a, ::mlir::Value b, /*optional*/::mlir::Value scaleFactor, bool relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(a), std::forward(b), std::forward(scaleFactor), std::forward(relu)); } void ConvertF32x2ToS2F6x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, /*optional*/::mlir::Value scaleFactor, bool relu) { odsState.addOperands(a); odsState.addOperands(b); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x2ToS2F6x2Op ConvertF32x2ToS2F6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, /*optional*/::mlir::Value scaleFactor, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(scaleFactor), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToS2F6x2Op ConvertF32x2ToS2F6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, /*optional*/::mlir::Value scaleFactor, bool relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(scaleFactor), std::forward(relu)); } void ConvertF32x2ToS2F6x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF32x2ToS2F6x2Op ConvertF32x2ToS2F6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToS2F6x2Op ConvertF32x2ToS2F6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF32x2ToS2F6x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF32x2ToS2F6x2Op ConvertF32x2ToS2F6x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x2ToS2F6x2Op ConvertF32x2ToS2F6x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF32x2ToS2F6x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF32x2ToS2F6x2Op::verifyInvariantsImpl() { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*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_NVVMOps11(*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_NVVMOps10(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x2ToS2F6x2Op::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ConvertF32x2ToS2F6x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand aRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(&aRawOperand, 1); ::llvm::SMLoc aOperandsLoc; (void)aOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand bRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> bOperands(&bRawOperand, 1); ::llvm::SMLoc bOperandsLoc; (void)bOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> scaleFactorOperands; ::llvm::SMLoc scaleFactorOperandsLoc; (void)scaleFactorOperandsLoc; ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); aOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(aRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); bOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(bRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { scaleFactorOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); scaleFactorOperands.push_back(operand); } } } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getF32Type(); ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(16); result.addTypes(dstTypes); if (parser.resolveOperands(aOperands, odsBuildableType0, aOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(bOperands, odsBuildableType0, bOperandsLoc, result.operands)) return ::mlir::failure(); if (!scaleFactorOperands.empty()) { if (parser.resolveOperands(scaleFactorOperands, odsBuildableType1, scaleFactorOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void ConvertF32x2ToS2F6x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getA(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getB(); if (getScaleFactor()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getScaleFactor()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF32x2ToS2F6x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF32x2ToS2F6x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF32x4ToF4x4Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF32x4ToF4x4OpGenericAdaptorBase::ConvertF32x4ToF4x4OpGenericAdaptorBase(ConvertF32x4ToF4x4Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::BoolAttr ConvertF32x4ToF4x4OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF32x4ToF4x4OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF32x4ToF4x4OpGenericAdaptorBase::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } } // namespace detail ConvertF32x4ToF4x4OpAdaptor::ConvertF32x4ToF4x4OpAdaptor(ConvertF32x4ToF4x4Op op) : ConvertF32x4ToF4x4OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF32x4ToF4x4OpAdaptor::verify(::mlir::Location loc) { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitError(loc, "'nvvm.convert.f32x4.to.f4x4' op requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f32x4.to.f4x4' op attribute 'relu' failed to satisfy constraint: bool attribute"); if (tblgen_dstTy && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_dstTy))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))) && ((true)))) return emitError(loc, "'nvvm.convert.f32x4.to.f4x4' op attribute 'dstTy' failed to satisfy constraint: any type attribute"); return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x4ToF4x4Op::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.dstTy; auto attr = dict.get("dstTy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dstTy` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF32x4ToF4x4Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.dstTy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dstTy", propStorage)); } { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF32x4ToF4x4Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.dstTy.getAsOpaquePointer()), llvm::hash_value(prop.relu.getAsOpaquePointer())); } std::optional ConvertF32x4ToF4x4Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "dstTy") return prop.dstTy; if (name == "relu") return prop.relu; return std::nullopt; } void ConvertF32x4ToF4x4Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "dstTy") { prop.dstTy = ::llvm::dyn_cast_or_null>(value); return; } if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF32x4ToF4x4Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.dstTy) attrs.append("dstTy", prop.dstTy); if (prop.relu) attrs.append("relu", prop.relu); } ::llvm::LogicalResult ConvertF32x4ToF4x4Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getDstTyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps14(attr, "dstTy", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x4ToF4x4Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.dstTy))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF32x4ToF4x4Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.dstTy); writer.writeOptionalAttribute(prop.relu); } bool ConvertF32x4ToF4x4Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF32x4ToF4x4Op::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } void ConvertF32x4ToF4x4Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF32x4ToF4x4Op::setDstTy(::mlir::Type attrValue) { getProperties().dstTy = ::mlir::TypeAttr::get(attrValue); } void ConvertF32x4ToF4x4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); odsState.addOperands(rbits); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; odsState.addTypes(dst); } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); } void ConvertF32x4ToF4x4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); odsState.addOperands(rbits); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertF32x4ToF4x4Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); } void ConvertF32x4ToF4x4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); odsState.addOperands(rbits); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); } void ConvertF32x4ToF4x4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.addOperands(rbits); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); odsState.addTypes(dst); } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); } void ConvertF32x4ToF4x4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.addOperands(rbits); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertF32x4ToF4x4Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); } void ConvertF32x4ToF4x4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.addOperands(rbits); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); } void ConvertF32x4ToF4x4Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF32x4ToF4x4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertF32x4ToF4x4Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ConvertF32x4ToF4x4Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF32x4ToF4x4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertF32x4ToF4x4Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF4x4Op ConvertF32x4ToF4x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF32x4ToF4x4Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF32x4ToF4x4Op::verifyInvariantsImpl() { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitOpError("requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps14(*this, tblgen_dstTy, "dstTy"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps14(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps11(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x4ToF4x4Op::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ConvertF32x4ToF4x4Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(16); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ConvertF32x4ToF4x4Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rbitsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rbitsOperands(&rbitsRawOperand, 1); ::llvm::SMLoc rbitsOperandsLoc; (void)rbitsOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); ::mlir::TypeAttr dstTyAttr; srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rbitsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rbitsRawOperand)) 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(dstTyAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (dstTyAttr) result.getOrAddProperties().dstTy = dstTyAttr; if (parser.parseRParen()) return ::mlir::failure(); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); result.addTypes(dstTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rbitsOperands, odsBuildableType0, rbitsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertF32x4ToF4x4Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRbits(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("dstTy"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getDstTyAttr()); _odsPrinter << ")"; } void ConvertF32x4ToF4x4Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF32x4ToF4x4Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF32x4ToF4x4OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF32x4ToF6x4Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF32x4ToF6x4OpGenericAdaptorBase::ConvertF32x4ToF6x4OpGenericAdaptorBase(ConvertF32x4ToF6x4Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::BoolAttr ConvertF32x4ToF6x4OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF32x4ToF6x4OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF32x4ToF6x4OpGenericAdaptorBase::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } } // namespace detail ConvertF32x4ToF6x4OpAdaptor::ConvertF32x4ToF6x4OpAdaptor(ConvertF32x4ToF6x4Op op) : ConvertF32x4ToF6x4OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF32x4ToF6x4OpAdaptor::verify(::mlir::Location loc) { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitError(loc, "'nvvm.convert.f32x4.to.f6x4' op requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f32x4.to.f6x4' op attribute 'relu' failed to satisfy constraint: bool attribute"); if (tblgen_dstTy && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_dstTy))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))) && ((true)))) return emitError(loc, "'nvvm.convert.f32x4.to.f6x4' op attribute 'dstTy' failed to satisfy constraint: any type attribute"); return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x4ToF6x4Op::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.dstTy; auto attr = dict.get("dstTy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dstTy` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF32x4ToF6x4Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.dstTy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dstTy", propStorage)); } { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF32x4ToF6x4Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.dstTy.getAsOpaquePointer()), llvm::hash_value(prop.relu.getAsOpaquePointer())); } std::optional ConvertF32x4ToF6x4Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "dstTy") return prop.dstTy; if (name == "relu") return prop.relu; return std::nullopt; } void ConvertF32x4ToF6x4Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "dstTy") { prop.dstTy = ::llvm::dyn_cast_or_null>(value); return; } if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF32x4ToF6x4Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.dstTy) attrs.append("dstTy", prop.dstTy); if (prop.relu) attrs.append("relu", prop.relu); } ::llvm::LogicalResult ConvertF32x4ToF6x4Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getDstTyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps14(attr, "dstTy", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x4ToF6x4Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.dstTy))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF32x4ToF6x4Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.dstTy); writer.writeOptionalAttribute(prop.relu); } bool ConvertF32x4ToF6x4Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF32x4ToF6x4Op::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } void ConvertF32x4ToF6x4Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF32x4ToF6x4Op::setDstTy(::mlir::Type attrValue) { getProperties().dstTy = ::mlir::TypeAttr::get(attrValue); } void ConvertF32x4ToF6x4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); odsState.addOperands(rbits); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; odsState.addTypes(dst); } ConvertF32x4ToF6x4Op ConvertF32x4ToF6x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF6x4Op ConvertF32x4ToF6x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); } void ConvertF32x4ToF6x4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); odsState.addOperands(rbits); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x4ToF6x4Op ConvertF32x4ToF6x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF6x4Op ConvertF32x4ToF6x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); } void ConvertF32x4ToF6x4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.addOperands(rbits); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); odsState.addTypes(dst); } ConvertF32x4ToF6x4Op ConvertF32x4ToF6x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF6x4Op ConvertF32x4ToF6x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); } void ConvertF32x4ToF6x4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.addOperands(rbits); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x4ToF6x4Op ConvertF32x4ToF6x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF6x4Op ConvertF32x4ToF6x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); } void ConvertF32x4ToF6x4Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF32x4ToF6x4Op ConvertF32x4ToF6x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF6x4Op ConvertF32x4ToF6x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF32x4ToF6x4Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF32x4ToF6x4Op ConvertF32x4ToF6x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF6x4Op ConvertF32x4ToF6x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF32x4ToF6x4Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF32x4ToF6x4Op::verifyInvariantsImpl() { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitOpError("requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps14(*this, tblgen_dstTy, "dstTy"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps14(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps15(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x4ToF6x4Op::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ConvertF32x4ToF6x4Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rbitsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rbitsOperands(&rbitsRawOperand, 1); ::llvm::SMLoc rbitsOperandsLoc; (void)rbitsOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); ::mlir::TypeAttr dstTyAttr; srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rbitsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rbitsRawOperand)) 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(dstTyAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (dstTyAttr) result.getOrAddProperties().dstTy = dstTyAttr; if (parser.parseRParen()) return ::mlir::failure(); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); result.addTypes(dstTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rbitsOperands, odsBuildableType0, rbitsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertF32x4ToF6x4Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRbits(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("dstTy"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getDstTyAttr()); _odsPrinter << ")"; } void ConvertF32x4ToF6x4Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF32x4ToF6x4Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF32x4ToF6x4OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF32x4ToF8x4Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF32x4ToF8x4OpGenericAdaptorBase::ConvertF32x4ToF8x4OpGenericAdaptorBase(ConvertF32x4ToF8x4Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::BoolAttr ConvertF32x4ToF8x4OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF32x4ToF8x4OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF32x4ToF8x4OpGenericAdaptorBase::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } } // namespace detail ConvertF32x4ToF8x4OpAdaptor::ConvertF32x4ToF8x4OpAdaptor(ConvertF32x4ToF8x4Op op) : ConvertF32x4ToF8x4OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF32x4ToF8x4OpAdaptor::verify(::mlir::Location loc) { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitError(loc, "'nvvm.convert.f32x4.to.f8x4' op requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f32x4.to.f8x4' op attribute 'relu' failed to satisfy constraint: bool attribute"); if (tblgen_dstTy && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_dstTy))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_dstTy).getValue()))) && ((true)))) return emitError(loc, "'nvvm.convert.f32x4.to.f8x4' op attribute 'dstTy' failed to satisfy constraint: any type attribute"); return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x4ToF8x4Op::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.dstTy; auto attr = dict.get("dstTy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dstTy` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF32x4ToF8x4Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.dstTy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dstTy", propStorage)); } { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF32x4ToF8x4Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.dstTy.getAsOpaquePointer()), llvm::hash_value(prop.relu.getAsOpaquePointer())); } std::optional ConvertF32x4ToF8x4Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "dstTy") return prop.dstTy; if (name == "relu") return prop.relu; return std::nullopt; } void ConvertF32x4ToF8x4Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "dstTy") { prop.dstTy = ::llvm::dyn_cast_or_null>(value); return; } if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF32x4ToF8x4Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.dstTy) attrs.append("dstTy", prop.dstTy); if (prop.relu) attrs.append("relu", prop.relu); } ::llvm::LogicalResult ConvertF32x4ToF8x4Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getDstTyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps14(attr, "dstTy", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x4ToF8x4Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.dstTy))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF32x4ToF8x4Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.dstTy); writer.writeOptionalAttribute(prop.relu); } bool ConvertF32x4ToF8x4Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::Type ConvertF32x4ToF8x4Op::getDstTy() { auto attr = getDstTyAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } void ConvertF32x4ToF8x4Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF32x4ToF8x4Op::setDstTy(::mlir::Type attrValue) { getProperties().dstTy = ::mlir::TypeAttr::get(attrValue); } void ConvertF32x4ToF8x4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); odsState.addOperands(rbits); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; odsState.addTypes(dst); } ConvertF32x4ToF8x4Op ConvertF32x4ToF8x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF8x4Op ConvertF32x4ToF8x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); } void ConvertF32x4ToF8x4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { odsState.addOperands(src); odsState.addOperands(rbits); if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.getOrAddProperties().dstTy = dstTy; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x4ToF8x4Op ConvertF32x4ToF8x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF8x4Op ConvertF32x4ToF8x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, ::mlir::BoolAttr relu, ::mlir::TypeAttr dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); } void ConvertF32x4ToF8x4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.addOperands(rbits); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); odsState.addTypes(dst); } ConvertF32x4ToF8x4Op ConvertF32x4ToF8x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF8x4Op ConvertF32x4ToF8x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); } void ConvertF32x4ToF8x4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { odsState.addOperands(src); odsState.addOperands(rbits); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().dstTy = ::mlir::TypeAttr::get(dstTy); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF32x4ToF8x4Op ConvertF32x4ToF8x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF8x4Op ConvertF32x4ToF8x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value rbits, bool relu, ::mlir::Type dstTy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(rbits), std::forward(relu), std::forward(dstTy)); } void ConvertF32x4ToF8x4Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF32x4ToF8x4Op ConvertF32x4ToF8x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF8x4Op ConvertF32x4ToF8x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF32x4ToF8x4Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF32x4ToF8x4Op ConvertF32x4ToF8x4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF32x4ToF8x4Op ConvertF32x4ToF8x4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF32x4ToF8x4Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF32x4ToF8x4Op::verifyInvariantsImpl() { auto tblgen_dstTy = getProperties().dstTy; (void)tblgen_dstTy; if (!tblgen_dstTy) return emitOpError("requires attribute 'dstTy'"); auto tblgen_relu = getProperties().relu; (void)tblgen_relu; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps14(*this, tblgen_dstTy, "dstTy"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps14(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps15(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF32x4ToF8x4Op::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ConvertF32x4ToF8x4Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rbitsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rbitsOperands(&rbitsRawOperand, 1); ::llvm::SMLoc rbitsOperandsLoc; (void)rbitsOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); ::mlir::TypeAttr dstTyAttr; srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rbitsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rbitsRawOperand)) 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(dstTyAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (dstTyAttr) result.getOrAddProperties().dstTy = dstTyAttr; if (parser.parseRParen()) return ::mlir::failure(); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); result.addTypes(dstTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rbitsOperands, odsBuildableType0, rbitsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertF32x4ToF8x4Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRbits(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("dstTy"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getDstTyAttr()); _odsPrinter << ")"; } void ConvertF32x4ToF8x4Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF32x4ToF8x4Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF32x4ToF8x4OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF4x2ToBF16x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF4x2ToBF16x2OpGenericAdaptorBase::ConvertF4x2ToBF16x2OpGenericAdaptorBase(ConvertF4x2ToBF16x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ConvertF4x2ToBF16x2OpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::Type ConvertF4x2ToBF16x2OpGenericAdaptorBase::getSrcType() { auto attr = getSrcTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::mlir::NVVM::SaturationModeAttr ConvertF4x2ToBF16x2OpGenericAdaptorBase::getSatAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::SaturationModeAttr>(getProperties().sat); return attr; } ::mlir::NVVM::SaturationMode ConvertF4x2ToBF16x2OpGenericAdaptorBase::getSat() { auto attr = getSatAttr(); return attr.getValue(); } ::mlir::BoolAttr ConvertF4x2ToBF16x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF4x2ToBF16x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } } // namespace detail ConvertF4x2ToBF16x2OpAdaptor::ConvertF4x2ToBF16x2OpAdaptor(ConvertF4x2ToBF16x2Op op) : ConvertF4x2ToBF16x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF4x2ToBF16x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; auto tblgen_srcType = getProperties().srcType; (void)tblgen_srcType; if (!tblgen_srcType) return emitError(loc, "'nvvm.convert.f4x2.to.bf16x2' op requires attribute 'srcType'"); if (tblgen_srcType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_srcType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue()))) && ((::llvm::isa<::mlir::Float4E2M1FNType>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue()))))) return emitError(loc, "'nvvm.convert.f4x2.to.bf16x2' op attribute 'srcType' failed to satisfy constraint: type attribute of f4E2M1FN type"); if (tblgen_sat && !(((::llvm::isa<::mlir::NVVM::SaturationModeAttr>(tblgen_sat))) && (((::llvm::cast<::mlir::NVVM::SaturationModeAttr>(tblgen_sat).getValue() == ::mlir::NVVM::SaturationMode::NONE)) || ((::llvm::cast<::mlir::NVVM::SaturationModeAttr>(tblgen_sat).getValue() == ::mlir::NVVM::SaturationMode::SATFINITE))))) return emitError(loc, "'nvvm.convert.f4x2.to.bf16x2' op attribute 'sat' failed to satisfy constraint: Describes the saturation mode whose value is one of {none, satfinite}"); if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f4x2.to.bf16x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair ConvertF4x2ToBF16x2Op::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 ConvertF4x2ToBF16x2Op::getScaleFactorMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult ConvertF4x2ToBF16x2Op::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.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sat; auto attr = dict.get("sat"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sat` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.srcType; auto attr = dict.get("srcType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `srcType` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF4x2ToBF16x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } { const auto &propStorage = prop.sat; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sat", propStorage)); } { const auto &propStorage = prop.srcType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("srcType", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF4x2ToBF16x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relu.getAsOpaquePointer()), llvm::hash_value(prop.sat.getAsOpaquePointer()), llvm::hash_value(prop.srcType.getAsOpaquePointer())); } std::optional ConvertF4x2ToBF16x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relu") return prop.relu; if (name == "sat") return prop.sat; if (name == "srcType") return prop.srcType; return std::nullopt; } void ConvertF4x2ToBF16x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sat") { prop.sat = ::llvm::dyn_cast_or_null>(value); return; } if (name == "srcType") { prop.srcType = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF4x2ToBF16x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relu) attrs.append("relu", prop.relu); if (prop.sat) attrs.append("sat", prop.sat); if (prop.srcType) attrs.append("srcType", prop.srcType); } ::llvm::LogicalResult ConvertF4x2ToBF16x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSatAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps16(attr, "sat", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSrcTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps15(attr, "srcType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF4x2ToBF16x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.sat))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.srcType))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF4x2ToBF16x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relu); writer.writeOptionalAttribute(prop.sat); writer.writeAttribute(prop.srcType); } ::mlir::Type ConvertF4x2ToBF16x2Op::getSrcType() { auto attr = getSrcTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::mlir::NVVM::SaturationMode ConvertF4x2ToBF16x2Op::getSat() { auto attr = getSatAttr(); return attr.getValue(); } bool ConvertF4x2ToBF16x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } void ConvertF4x2ToBF16x2Op::setSrcType(::mlir::Type attrValue) { getProperties().srcType = ::mlir::TypeAttr::get(attrValue); } void ConvertF4x2ToBF16x2Op::setSat(::mlir::NVVM::SaturationMode attrValue) { getProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ConvertF4x2ToBF16x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF4x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().srcType = srcType; if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.addTypes(dst); } ConvertF4x2ToBF16x2Op ConvertF4x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF4x2ToBF16x2Op ConvertF4x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); } void ConvertF4x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().srcType = srcType; if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF4x2ToBF16x2Op ConvertF4x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF4x2ToBF16x2Op ConvertF4x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); } void ConvertF4x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().srcType = ::mlir::TypeAttr::get(srcType); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.addTypes(dst); } ConvertF4x2ToBF16x2Op ConvertF4x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF4x2ToBF16x2Op ConvertF4x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); } void ConvertF4x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().srcType = ::mlir::TypeAttr::get(srcType); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF4x2ToBF16x2Op ConvertF4x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF4x2ToBF16x2Op ConvertF4x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); } void ConvertF4x2ToBF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF4x2ToBF16x2Op ConvertF4x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF4x2ToBF16x2Op ConvertF4x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF4x2ToBF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF4x2ToBF16x2Op ConvertF4x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF4x2ToBF16x2Op ConvertF4x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF4x2ToBF16x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.sat) properties.sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF4x2ToBF16x2Op::verifyInvariantsImpl() { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; auto tblgen_srcType = getProperties().srcType; (void)tblgen_srcType; if (!tblgen_srcType) return emitOpError("requires attribute 'srcType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps15(*this, tblgen_srcType, "srcType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps16(*this, tblgen_sat, "sat"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps9(*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_NVVMOps11(*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_NVVMOps8(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF4x2ToBF16x2Op::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ConvertF4x2ToBF16x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> scaleFactorOperands; ::llvm::SMLoc scaleFactorOperandsLoc; (void)scaleFactorOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::TypeAttr srcTypeAttr; ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { scaleFactorOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); scaleFactorOperands.push_back(operand); } } } { 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(); srcRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(srcTypeAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (srcTypeAttr) result.getOrAddProperties().srcType = srcTypeAttr; if (parser.parseRParen()) return ::mlir::failure(); if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(16); result.addTypes(dstTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); if (!scaleFactorOperands.empty()) { if (parser.resolveOperands(scaleFactorOperands, odsBuildableType0, scaleFactorOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void ConvertF4x2ToBF16x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); if (getScaleFactor()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getScaleFactor()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("srcType"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getSatAttr(); if(attr && (attr == ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE))) elidedAttrs.push_back("sat"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getSrcTypeAttr()); _odsPrinter << ")"; _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF4x2ToBF16x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF4x2ToBF16x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF4x2ToF16x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF4x2ToF16x2OpGenericAdaptorBase::ConvertF4x2ToF16x2OpGenericAdaptorBase(ConvertF4x2ToF16x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::Type ConvertF4x2ToF16x2OpGenericAdaptorBase::getSrcType() { auto attr = getSrcTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::mlir::BoolAttr ConvertF4x2ToF16x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF4x2ToF16x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } } // namespace detail ConvertF4x2ToF16x2OpAdaptor::ConvertF4x2ToF16x2OpAdaptor(ConvertF4x2ToF16x2Op op) : ConvertF4x2ToF16x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF4x2ToF16x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_srcType = getProperties().srcType; (void)tblgen_srcType; if (!tblgen_srcType) return emitError(loc, "'nvvm.convert.f4x2.to.f16x2' op requires attribute 'srcType'"); if (tblgen_srcType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_srcType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue()))) && ((::llvm::isa<::mlir::Float4E2M1FNType>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue()))))) return emitError(loc, "'nvvm.convert.f4x2.to.f16x2' op attribute 'srcType' failed to satisfy constraint: type attribute of f4E2M1FN type"); if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f4x2.to.f16x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult ConvertF4x2ToF16x2Op::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.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.srcType; auto attr = dict.get("srcType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `srcType` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF4x2ToF16x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } { const auto &propStorage = prop.srcType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("srcType", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF4x2ToF16x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relu.getAsOpaquePointer()), llvm::hash_value(prop.srcType.getAsOpaquePointer())); } std::optional ConvertF4x2ToF16x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relu") return prop.relu; if (name == "srcType") return prop.srcType; return std::nullopt; } void ConvertF4x2ToF16x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } if (name == "srcType") { prop.srcType = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF4x2ToF16x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relu) attrs.append("relu", prop.relu); if (prop.srcType) attrs.append("srcType", prop.srcType); } ::llvm::LogicalResult ConvertF4x2ToF16x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSrcTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps15(attr, "srcType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF4x2ToF16x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.srcType))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF4x2ToF16x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relu); writer.writeAttribute(prop.srcType); } ::mlir::Type ConvertF4x2ToF16x2Op::getSrcType() { auto attr = getSrcTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } bool ConvertF4x2ToF16x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } void ConvertF4x2ToF16x2Op::setSrcType(::mlir::Type attrValue) { getProperties().srcType = ::mlir::TypeAttr::get(attrValue); } void ConvertF4x2ToF16x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF4x2ToF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { odsState.addOperands(src); odsState.getOrAddProperties().srcType = srcType; if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.addTypes(dst); } ConvertF4x2ToF16x2Op ConvertF4x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(srcType), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF4x2ToF16x2Op ConvertF4x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(srcType), std::forward(relu)); } void ConvertF4x2ToF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { odsState.addOperands(src); odsState.getOrAddProperties().srcType = srcType; if (relu) { odsState.getOrAddProperties().relu = relu; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF4x2ToF16x2Op ConvertF4x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(srcType), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF4x2ToF16x2Op ConvertF4x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(srcType), std::forward(relu)); } void ConvertF4x2ToF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::Type srcType, bool relu) { odsState.addOperands(src); odsState.getOrAddProperties().srcType = ::mlir::TypeAttr::get(srcType); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.addTypes(dst); } ConvertF4x2ToF16x2Op ConvertF4x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::Type srcType, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(srcType), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF4x2ToF16x2Op ConvertF4x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::Type srcType, bool relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(srcType), std::forward(relu)); } void ConvertF4x2ToF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Type srcType, bool relu) { odsState.addOperands(src); odsState.getOrAddProperties().srcType = ::mlir::TypeAttr::get(srcType); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF4x2ToF16x2Op ConvertF4x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Type srcType, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(srcType), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF4x2ToF16x2Op ConvertF4x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Type srcType, bool relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(srcType), std::forward(relu)); } void ConvertF4x2ToF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF4x2ToF16x2Op ConvertF4x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF4x2ToF16x2Op ConvertF4x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF4x2ToF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF4x2ToF16x2Op ConvertF4x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF4x2ToF16x2Op ConvertF4x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF4x2ToF16x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF4x2ToF16x2Op::verifyInvariantsImpl() { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_srcType = getProperties().srcType; (void)tblgen_srcType; if (!tblgen_srcType) return emitOpError("requires attribute 'srcType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps15(*this, tblgen_srcType, "srcType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps9(*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_NVVMOps12(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF4x2ToF16x2Op::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ConvertF4x2ToF16x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::TypeAttr srcTypeAttr; ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) 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(); srcRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(srcTypeAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (srcTypeAttr) result.getOrAddProperties().srcType = srcTypeAttr; if (parser.parseRParen()) return ::mlir::failure(); if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } result.addTypes(dstTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertF4x2ToF16x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("srcType"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getSrcTypeAttr()); _odsPrinter << ")"; _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF4x2ToF16x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF4x2ToF16x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF6x2ToBF16x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF6x2ToBF16x2OpGenericAdaptorBase::ConvertF6x2ToBF16x2OpGenericAdaptorBase(ConvertF6x2ToBF16x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ConvertF6x2ToBF16x2OpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::Type ConvertF6x2ToBF16x2OpGenericAdaptorBase::getSrcType() { auto attr = getSrcTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::mlir::NVVM::SaturationModeAttr ConvertF6x2ToBF16x2OpGenericAdaptorBase::getSatAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::SaturationModeAttr>(getProperties().sat); return attr; } ::mlir::NVVM::SaturationMode ConvertF6x2ToBF16x2OpGenericAdaptorBase::getSat() { auto attr = getSatAttr(); return attr.getValue(); } ::mlir::BoolAttr ConvertF6x2ToBF16x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF6x2ToBF16x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } } // namespace detail ConvertF6x2ToBF16x2OpAdaptor::ConvertF6x2ToBF16x2OpAdaptor(ConvertF6x2ToBF16x2Op op) : ConvertF6x2ToBF16x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF6x2ToBF16x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; auto tblgen_srcType = getProperties().srcType; (void)tblgen_srcType; if (!tblgen_srcType) return emitError(loc, "'nvvm.convert.f6x2.to.bf16x2' op requires attribute 'srcType'"); if (tblgen_srcType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_srcType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue()))) && (((::llvm::isa<::mlir::Float6E2M3FNType>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue()))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue())))))) return emitError(loc, "'nvvm.convert.f6x2.to.bf16x2' op attribute 'srcType' failed to satisfy constraint: type attribute of f6E2M3FN type or f6E3M2FN type"); if (tblgen_sat && !(((::llvm::isa<::mlir::NVVM::SaturationModeAttr>(tblgen_sat))) && (((::llvm::cast<::mlir::NVVM::SaturationModeAttr>(tblgen_sat).getValue() == ::mlir::NVVM::SaturationMode::NONE)) || ((::llvm::cast<::mlir::NVVM::SaturationModeAttr>(tblgen_sat).getValue() == ::mlir::NVVM::SaturationMode::SATFINITE))))) return emitError(loc, "'nvvm.convert.f6x2.to.bf16x2' op attribute 'sat' failed to satisfy constraint: Describes the saturation mode whose value is one of {none, satfinite}"); if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f6x2.to.bf16x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair ConvertF6x2ToBF16x2Op::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 ConvertF6x2ToBF16x2Op::getScaleFactorMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult ConvertF6x2ToBF16x2Op::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.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sat; auto attr = dict.get("sat"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sat` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.srcType; auto attr = dict.get("srcType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `srcType` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF6x2ToBF16x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } { const auto &propStorage = prop.sat; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sat", propStorage)); } { const auto &propStorage = prop.srcType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("srcType", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF6x2ToBF16x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relu.getAsOpaquePointer()), llvm::hash_value(prop.sat.getAsOpaquePointer()), llvm::hash_value(prop.srcType.getAsOpaquePointer())); } std::optional ConvertF6x2ToBF16x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relu") return prop.relu; if (name == "sat") return prop.sat; if (name == "srcType") return prop.srcType; return std::nullopt; } void ConvertF6x2ToBF16x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sat") { prop.sat = ::llvm::dyn_cast_or_null>(value); return; } if (name == "srcType") { prop.srcType = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF6x2ToBF16x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relu) attrs.append("relu", prop.relu); if (prop.sat) attrs.append("sat", prop.sat); if (prop.srcType) attrs.append("srcType", prop.srcType); } ::llvm::LogicalResult ConvertF6x2ToBF16x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSatAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps16(attr, "sat", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSrcTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps10(attr, "srcType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF6x2ToBF16x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.sat))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.srcType))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF6x2ToBF16x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relu); writer.writeOptionalAttribute(prop.sat); writer.writeAttribute(prop.srcType); } ::mlir::Type ConvertF6x2ToBF16x2Op::getSrcType() { auto attr = getSrcTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::mlir::NVVM::SaturationMode ConvertF6x2ToBF16x2Op::getSat() { auto attr = getSatAttr(); return attr.getValue(); } bool ConvertF6x2ToBF16x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } void ConvertF6x2ToBF16x2Op::setSrcType(::mlir::Type attrValue) { getProperties().srcType = ::mlir::TypeAttr::get(attrValue); } void ConvertF6x2ToBF16x2Op::setSat(::mlir::NVVM::SaturationMode attrValue) { getProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ConvertF6x2ToBF16x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF6x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().srcType = srcType; if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.addTypes(dst); } ConvertF6x2ToBF16x2Op ConvertF6x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF6x2ToBF16x2Op ConvertF6x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); } void ConvertF6x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().srcType = srcType; if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF6x2ToBF16x2Op ConvertF6x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF6x2ToBF16x2Op ConvertF6x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); } void ConvertF6x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().srcType = ::mlir::TypeAttr::get(srcType); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.addTypes(dst); } ConvertF6x2ToBF16x2Op ConvertF6x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF6x2ToBF16x2Op ConvertF6x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); } void ConvertF6x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().srcType = ::mlir::TypeAttr::get(srcType); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF6x2ToBF16x2Op ConvertF6x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF6x2ToBF16x2Op ConvertF6x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); } void ConvertF6x2ToBF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF6x2ToBF16x2Op ConvertF6x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF6x2ToBF16x2Op ConvertF6x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF6x2ToBF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF6x2ToBF16x2Op ConvertF6x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF6x2ToBF16x2Op ConvertF6x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF6x2ToBF16x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.sat) properties.sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF6x2ToBF16x2Op::verifyInvariantsImpl() { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; auto tblgen_srcType = getProperties().srcType; (void)tblgen_srcType; if (!tblgen_srcType) return emitOpError("requires attribute 'srcType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps10(*this, tblgen_srcType, "srcType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps16(*this, tblgen_sat, "sat"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps16(*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_NVVMOps11(*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_NVVMOps8(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF6x2ToBF16x2Op::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ConvertF6x2ToBF16x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> scaleFactorOperands; ::llvm::SMLoc scaleFactorOperandsLoc; (void)scaleFactorOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::TypeAttr srcTypeAttr; ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { scaleFactorOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); scaleFactorOperands.push_back(operand); } } } { 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(srcTypeAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (srcTypeAttr) result.getOrAddProperties().srcType = srcTypeAttr; if (parser.parseRParen()) return ::mlir::failure(); if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(16); result.addTypes(dstTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); if (!scaleFactorOperands.empty()) { if (parser.resolveOperands(scaleFactorOperands, odsBuildableType0, scaleFactorOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void ConvertF6x2ToBF16x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); if (getScaleFactor()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getScaleFactor()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("srcType"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getSatAttr(); if(attr && (attr == ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE))) elidedAttrs.push_back("sat"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getSrcTypeAttr()); _odsPrinter << ")"; _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF6x2ToBF16x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF6x2ToBF16x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF6x2ToF16x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF6x2ToF16x2OpGenericAdaptorBase::ConvertF6x2ToF16x2OpGenericAdaptorBase(ConvertF6x2ToF16x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::Type ConvertF6x2ToF16x2OpGenericAdaptorBase::getSrcType() { auto attr = getSrcTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::mlir::BoolAttr ConvertF6x2ToF16x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF6x2ToF16x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } } // namespace detail ConvertF6x2ToF16x2OpAdaptor::ConvertF6x2ToF16x2OpAdaptor(ConvertF6x2ToF16x2Op op) : ConvertF6x2ToF16x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF6x2ToF16x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_srcType = getProperties().srcType; (void)tblgen_srcType; if (!tblgen_srcType) return emitError(loc, "'nvvm.convert.f6x2.to.f16x2' op requires attribute 'srcType'"); if (tblgen_srcType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_srcType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue()))) && (((::llvm::isa<::mlir::Float6E2M3FNType>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue()))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue())))))) return emitError(loc, "'nvvm.convert.f6x2.to.f16x2' op attribute 'srcType' failed to satisfy constraint: type attribute of f6E2M3FN type or f6E3M2FN type"); if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f6x2.to.f16x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult ConvertF6x2ToF16x2Op::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.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.srcType; auto attr = dict.get("srcType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `srcType` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF6x2ToF16x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } { const auto &propStorage = prop.srcType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("srcType", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF6x2ToF16x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relu.getAsOpaquePointer()), llvm::hash_value(prop.srcType.getAsOpaquePointer())); } std::optional ConvertF6x2ToF16x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relu") return prop.relu; if (name == "srcType") return prop.srcType; return std::nullopt; } void ConvertF6x2ToF16x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } if (name == "srcType") { prop.srcType = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF6x2ToF16x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relu) attrs.append("relu", prop.relu); if (prop.srcType) attrs.append("srcType", prop.srcType); } ::llvm::LogicalResult ConvertF6x2ToF16x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSrcTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps10(attr, "srcType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF6x2ToF16x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.srcType))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF6x2ToF16x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relu); writer.writeAttribute(prop.srcType); } ::mlir::Type ConvertF6x2ToF16x2Op::getSrcType() { auto attr = getSrcTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } bool ConvertF6x2ToF16x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } void ConvertF6x2ToF16x2Op::setSrcType(::mlir::Type attrValue) { getProperties().srcType = ::mlir::TypeAttr::get(attrValue); } void ConvertF6x2ToF16x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF6x2ToF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { odsState.addOperands(src); odsState.getOrAddProperties().srcType = srcType; if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.addTypes(dst); } ConvertF6x2ToF16x2Op ConvertF6x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(srcType), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF6x2ToF16x2Op ConvertF6x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(srcType), std::forward(relu)); } void ConvertF6x2ToF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { odsState.addOperands(src); odsState.getOrAddProperties().srcType = srcType; if (relu) { odsState.getOrAddProperties().relu = relu; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF6x2ToF16x2Op ConvertF6x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(srcType), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF6x2ToF16x2Op ConvertF6x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(srcType), std::forward(relu)); } void ConvertF6x2ToF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::Type srcType, bool relu) { odsState.addOperands(src); odsState.getOrAddProperties().srcType = ::mlir::TypeAttr::get(srcType); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.addTypes(dst); } ConvertF6x2ToF16x2Op ConvertF6x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::Type srcType, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(srcType), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF6x2ToF16x2Op ConvertF6x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::Type srcType, bool relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(srcType), std::forward(relu)); } void ConvertF6x2ToF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Type srcType, bool relu) { odsState.addOperands(src); odsState.getOrAddProperties().srcType = ::mlir::TypeAttr::get(srcType); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF6x2ToF16x2Op ConvertF6x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Type srcType, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(srcType), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF6x2ToF16x2Op ConvertF6x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Type srcType, bool relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(srcType), std::forward(relu)); } void ConvertF6x2ToF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF6x2ToF16x2Op ConvertF6x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF6x2ToF16x2Op ConvertF6x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF6x2ToF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF6x2ToF16x2Op ConvertF6x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF6x2ToF16x2Op ConvertF6x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF6x2ToF16x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF6x2ToF16x2Op::verifyInvariantsImpl() { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_srcType = getProperties().srcType; (void)tblgen_srcType; if (!tblgen_srcType) return emitOpError("requires attribute 'srcType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps10(*this, tblgen_srcType, "srcType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps16(*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_NVVMOps12(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF6x2ToF16x2Op::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ConvertF6x2ToF16x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::TypeAttr srcTypeAttr; ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(srcTypeAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (srcTypeAttr) result.getOrAddProperties().srcType = srcTypeAttr; if (parser.parseRParen()) return ::mlir::failure(); if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } result.addTypes(dstTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertF6x2ToF16x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("srcType"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getSrcTypeAttr()); _odsPrinter << ")"; _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF6x2ToF16x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF6x2ToF16x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF8x2ToBF16x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF8x2ToBF16x2OpGenericAdaptorBase::ConvertF8x2ToBF16x2OpGenericAdaptorBase(ConvertF8x2ToBF16x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ConvertF8x2ToBF16x2OpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::Type ConvertF8x2ToBF16x2OpGenericAdaptorBase::getSrcType() { auto attr = getSrcTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::mlir::NVVM::SaturationModeAttr ConvertF8x2ToBF16x2OpGenericAdaptorBase::getSatAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::SaturationModeAttr>(getProperties().sat); return attr; } ::mlir::NVVM::SaturationMode ConvertF8x2ToBF16x2OpGenericAdaptorBase::getSat() { auto attr = getSatAttr(); return attr.getValue(); } ::mlir::BoolAttr ConvertF8x2ToBF16x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF8x2ToBF16x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } } // namespace detail ConvertF8x2ToBF16x2OpAdaptor::ConvertF8x2ToBF16x2OpAdaptor(ConvertF8x2ToBF16x2Op op) : ConvertF8x2ToBF16x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF8x2ToBF16x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; auto tblgen_srcType = getProperties().srcType; (void)tblgen_srcType; if (!tblgen_srcType) return emitError(loc, "'nvvm.convert.f8x2.to.bf16x2' op requires attribute 'srcType'"); if (tblgen_srcType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_srcType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue()))) && (((::llvm::isa<::mlir::Float8E8M0FNUType>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue()))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue()))) || ((::llvm::isa<::mlir::Float8E5M2Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue())))))) return emitError(loc, "'nvvm.convert.f8x2.to.bf16x2' op attribute 'srcType' failed to satisfy constraint: type attribute of f8E8M0FNU type or f8E4M3FN type or f8E5M2 type"); if (tblgen_sat && !(((::llvm::isa<::mlir::NVVM::SaturationModeAttr>(tblgen_sat))) && (((::llvm::cast<::mlir::NVVM::SaturationModeAttr>(tblgen_sat).getValue() == ::mlir::NVVM::SaturationMode::NONE)) || ((::llvm::cast<::mlir::NVVM::SaturationModeAttr>(tblgen_sat).getValue() == ::mlir::NVVM::SaturationMode::SATFINITE))))) return emitError(loc, "'nvvm.convert.f8x2.to.bf16x2' op attribute 'sat' failed to satisfy constraint: Describes the saturation mode whose value is one of {none, satfinite}"); if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f8x2.to.bf16x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair ConvertF8x2ToBF16x2Op::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 ConvertF8x2ToBF16x2Op::getScaleFactorMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult ConvertF8x2ToBF16x2Op::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.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sat; auto attr = dict.get("sat"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sat` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.srcType; auto attr = dict.get("srcType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `srcType` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF8x2ToBF16x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } { const auto &propStorage = prop.sat; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sat", propStorage)); } { const auto &propStorage = prop.srcType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("srcType", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF8x2ToBF16x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relu.getAsOpaquePointer()), llvm::hash_value(prop.sat.getAsOpaquePointer()), llvm::hash_value(prop.srcType.getAsOpaquePointer())); } std::optional ConvertF8x2ToBF16x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relu") return prop.relu; if (name == "sat") return prop.sat; if (name == "srcType") return prop.srcType; return std::nullopt; } void ConvertF8x2ToBF16x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sat") { prop.sat = ::llvm::dyn_cast_or_null>(value); return; } if (name == "srcType") { prop.srcType = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF8x2ToBF16x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relu) attrs.append("relu", prop.relu); if (prop.sat) attrs.append("sat", prop.sat); if (prop.srcType) attrs.append("srcType", prop.srcType); } ::llvm::LogicalResult ConvertF8x2ToBF16x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSatAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps16(attr, "sat", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSrcTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps13(attr, "srcType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF8x2ToBF16x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.sat))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.srcType))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF8x2ToBF16x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relu); writer.writeOptionalAttribute(prop.sat); writer.writeAttribute(prop.srcType); } ::mlir::Type ConvertF8x2ToBF16x2Op::getSrcType() { auto attr = getSrcTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::mlir::NVVM::SaturationMode ConvertF8x2ToBF16x2Op::getSat() { auto attr = getSatAttr(); return attr.getValue(); } bool ConvertF8x2ToBF16x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } void ConvertF8x2ToBF16x2Op::setSrcType(::mlir::Type attrValue) { getProperties().srcType = ::mlir::TypeAttr::get(attrValue); } void ConvertF8x2ToBF16x2Op::setSat(::mlir::NVVM::SaturationMode attrValue) { getProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ConvertF8x2ToBF16x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF8x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().srcType = srcType; if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.addTypes(dst); } ConvertF8x2ToBF16x2Op ConvertF8x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF8x2ToBF16x2Op ConvertF8x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); } void ConvertF8x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().srcType = srcType; if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF8x2ToBF16x2Op ConvertF8x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF8x2ToBF16x2Op ConvertF8x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::TypeAttr srcType, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); } void ConvertF8x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().srcType = ::mlir::TypeAttr::get(srcType); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.addTypes(dst); } ConvertF8x2ToBF16x2Op ConvertF8x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF8x2ToBF16x2Op ConvertF8x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); } void ConvertF8x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().srcType = ::mlir::TypeAttr::get(srcType); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF8x2ToBF16x2Op ConvertF8x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF8x2ToBF16x2Op ConvertF8x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::Type srcType, ::mlir::NVVM::SaturationMode sat, bool relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(srcType), std::forward(sat), std::forward(relu)); } void ConvertF8x2ToBF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF8x2ToBF16x2Op ConvertF8x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF8x2ToBF16x2Op ConvertF8x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF8x2ToBF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF8x2ToBF16x2Op ConvertF8x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF8x2ToBF16x2Op ConvertF8x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF8x2ToBF16x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.sat) properties.sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF8x2ToBF16x2Op::verifyInvariantsImpl() { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; auto tblgen_srcType = getProperties().srcType; (void)tblgen_srcType; if (!tblgen_srcType) return emitOpError("requires attribute 'srcType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps13(*this, tblgen_srcType, "srcType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps16(*this, tblgen_sat, "sat"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps16(*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_NVVMOps11(*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_NVVMOps8(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF8x2ToBF16x2Op::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ConvertF8x2ToBF16x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> scaleFactorOperands; ::llvm::SMLoc scaleFactorOperandsLoc; (void)scaleFactorOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::TypeAttr srcTypeAttr; ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { scaleFactorOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); scaleFactorOperands.push_back(operand); } } } { 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(srcTypeAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (srcTypeAttr) result.getOrAddProperties().srcType = srcTypeAttr; if (parser.parseRParen()) return ::mlir::failure(); if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(16); result.addTypes(dstTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); if (!scaleFactorOperands.empty()) { if (parser.resolveOperands(scaleFactorOperands, odsBuildableType0, scaleFactorOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void ConvertF8x2ToBF16x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); if (getScaleFactor()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getScaleFactor()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("srcType"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getSatAttr(); if(attr && (attr == ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE))) elidedAttrs.push_back("sat"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getSrcTypeAttr()); _odsPrinter << ")"; _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF8x2ToBF16x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF8x2ToBF16x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertF8x2ToF16x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertF8x2ToF16x2OpGenericAdaptorBase::ConvertF8x2ToF16x2OpGenericAdaptorBase(ConvertF8x2ToF16x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::Type ConvertF8x2ToF16x2OpGenericAdaptorBase::getSrcType() { auto attr = getSrcTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::mlir::BoolAttr ConvertF8x2ToF16x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertF8x2ToF16x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } } // namespace detail ConvertF8x2ToF16x2OpAdaptor::ConvertF8x2ToF16x2OpAdaptor(ConvertF8x2ToF16x2Op op) : ConvertF8x2ToF16x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertF8x2ToF16x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_srcType = getProperties().srcType; (void)tblgen_srcType; if (!tblgen_srcType) return emitError(loc, "'nvvm.convert.f8x2.to.f16x2' op requires attribute 'srcType'"); if (tblgen_srcType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_srcType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue()))) && (((::llvm::isa<::mlir::Float8E4M3FNType>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue()))) || ((::llvm::isa<::mlir::Float8E5M2Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_srcType).getValue())))))) return emitError(loc, "'nvvm.convert.f8x2.to.f16x2' op attribute 'srcType' failed to satisfy constraint: type attribute of f8E4M3FN type or f8E5M2 type"); if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.f8x2.to.f16x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult ConvertF8x2ToF16x2Op::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.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.srcType; auto attr = dict.get("srcType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `srcType` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertF8x2ToF16x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } { const auto &propStorage = prop.srcType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("srcType", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertF8x2ToF16x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relu.getAsOpaquePointer()), llvm::hash_value(prop.srcType.getAsOpaquePointer())); } std::optional ConvertF8x2ToF16x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relu") return prop.relu; if (name == "srcType") return prop.srcType; return std::nullopt; } void ConvertF8x2ToF16x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } if (name == "srcType") { prop.srcType = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertF8x2ToF16x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relu) attrs.append("relu", prop.relu); if (prop.srcType) attrs.append("srcType", prop.srcType); } ::llvm::LogicalResult ConvertF8x2ToF16x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSrcTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps17(attr, "srcType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertF8x2ToF16x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.srcType))) return ::mlir::failure(); return ::mlir::success(); } void ConvertF8x2ToF16x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relu); writer.writeAttribute(prop.srcType); } ::mlir::Type ConvertF8x2ToF16x2Op::getSrcType() { auto attr = getSrcTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } bool ConvertF8x2ToF16x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } void ConvertF8x2ToF16x2Op::setSrcType(::mlir::Type attrValue) { getProperties().srcType = ::mlir::TypeAttr::get(attrValue); } void ConvertF8x2ToF16x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertF8x2ToF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { odsState.addOperands(src); odsState.getOrAddProperties().srcType = srcType; if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.addTypes(dst); } ConvertF8x2ToF16x2Op ConvertF8x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(srcType), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF8x2ToF16x2Op ConvertF8x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(srcType), std::forward(relu)); } void ConvertF8x2ToF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { odsState.addOperands(src); odsState.getOrAddProperties().srcType = srcType; if (relu) { odsState.getOrAddProperties().relu = relu; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF8x2ToF16x2Op ConvertF8x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(srcType), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF8x2ToF16x2Op ConvertF8x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::TypeAttr srcType, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(srcType), std::forward(relu)); } void ConvertF8x2ToF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::Type srcType, bool relu) { odsState.addOperands(src); odsState.getOrAddProperties().srcType = ::mlir::TypeAttr::get(srcType); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.addTypes(dst); } ConvertF8x2ToF16x2Op ConvertF8x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::Type srcType, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(srcType), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF8x2ToF16x2Op ConvertF8x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::Type srcType, bool relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(srcType), std::forward(relu)); } void ConvertF8x2ToF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Type srcType, bool relu) { odsState.addOperands(src); odsState.getOrAddProperties().srcType = ::mlir::TypeAttr::get(srcType); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertF8x2ToF16x2Op ConvertF8x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Type srcType, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(srcType), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF8x2ToF16x2Op ConvertF8x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Type srcType, bool relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(srcType), std::forward(relu)); } void ConvertF8x2ToF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertF8x2ToF16x2Op ConvertF8x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF8x2ToF16x2Op ConvertF8x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertF8x2ToF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertF8x2ToF16x2Op ConvertF8x2ToF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertF8x2ToF16x2Op ConvertF8x2ToF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertF8x2ToF16x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertF8x2ToF16x2Op::verifyInvariantsImpl() { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_srcType = getProperties().srcType; (void)tblgen_srcType; if (!tblgen_srcType) return emitOpError("requires attribute 'srcType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps17(*this, tblgen_srcType, "srcType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps16(*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_NVVMOps12(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertF8x2ToF16x2Op::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ConvertF8x2ToF16x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::TypeAttr srcTypeAttr; ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(srcTypeAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (srcTypeAttr) result.getOrAddProperties().srcType = srcTypeAttr; if (parser.parseRParen()) return ::mlir::failure(); if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } result.addTypes(dstTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertF8x2ToF16x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("srcType"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getSrcTypeAttr()); _odsPrinter << ")"; _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertF8x2ToF16x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertF8x2ToF16x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertFloatToTF32Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertFloatToTF32OpGenericAdaptorBase::ConvertFloatToTF32OpGenericAdaptorBase(ConvertFloatToTF32Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::FPRoundingModeAttr ConvertFloatToTF32OpGenericAdaptorBase::getRndAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::FPRoundingModeAttr>(getProperties().rnd); return attr; } ::mlir::NVVM::FPRoundingMode ConvertFloatToTF32OpGenericAdaptorBase::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::NVVM::SaturationModeAttr ConvertFloatToTF32OpGenericAdaptorBase::getSatAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::SaturationModeAttr>(getProperties().sat); return attr; } ::mlir::NVVM::SaturationMode ConvertFloatToTF32OpGenericAdaptorBase::getSat() { auto attr = getSatAttr(); return attr.getValue(); } ::mlir::BoolAttr ConvertFloatToTF32OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertFloatToTF32OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } } // namespace detail ConvertFloatToTF32OpAdaptor::ConvertFloatToTF32OpAdaptor(ConvertFloatToTF32Op op) : ConvertFloatToTF32OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertFloatToTF32OpAdaptor::verify(::mlir::Location loc) { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (tblgen_rnd && !((::llvm::isa<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd)))) return emitError(loc, "'nvvm.convert.float.to.tf32' op attribute 'rnd' failed to satisfy constraint: NVVM FPRoundingMode kind"); if (tblgen_sat && !((::llvm::isa<::mlir::NVVM::SaturationModeAttr>(tblgen_sat)))) return emitError(loc, "'nvvm.convert.float.to.tf32' op attribute 'sat' failed to satisfy constraint: Describes the saturation mode"); if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.float.to.tf32' op attribute 'relu' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult ConvertFloatToTF32Op::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.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.rnd; auto attr = dict.get("rnd"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `rnd` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sat; auto attr = dict.get("sat"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sat` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertFloatToTF32Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } { const auto &propStorage = prop.rnd; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("rnd", propStorage)); } { const auto &propStorage = prop.sat; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sat", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertFloatToTF32Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relu.getAsOpaquePointer()), llvm::hash_value(prop.rnd.getAsOpaquePointer()), llvm::hash_value(prop.sat.getAsOpaquePointer())); } std::optional ConvertFloatToTF32Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relu") return prop.relu; if (name == "rnd") return prop.rnd; if (name == "sat") return prop.sat; return std::nullopt; } void ConvertFloatToTF32Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } if (name == "rnd") { prop.rnd = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sat") { prop.sat = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertFloatToTF32Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relu) attrs.append("relu", prop.relu); if (prop.rnd) attrs.append("rnd", prop.rnd); if (prop.sat) attrs.append("sat", prop.sat); } ::llvm::LogicalResult ConvertFloatToTF32Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRndAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps11(attr, "rnd", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSatAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps12(attr, "sat", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertFloatToTF32Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.rnd))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.sat))) return ::mlir::failure(); return ::mlir::success(); } void ConvertFloatToTF32Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relu); writer.writeOptionalAttribute(prop.rnd); writer.writeOptionalAttribute(prop.sat); } ::mlir::NVVM::FPRoundingMode ConvertFloatToTF32Op::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::NVVM::SaturationMode ConvertFloatToTF32Op::getSat() { auto attr = getSatAttr(); return attr.getValue(); } bool ConvertFloatToTF32Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } void ConvertFloatToTF32Op::setRnd(::mlir::NVVM::FPRoundingMode attrValue) { getProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ConvertFloatToTF32Op::setSat(::mlir::NVVM::SaturationMode attrValue) { getProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ConvertFloatToTF32Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertFloatToTF32Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { odsState.addOperands(src); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.addTypes(res); } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(res), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu)); } void ConvertFloatToTF32Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { odsState.addOperands(src); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertFloatToTF32Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu)); } void ConvertFloatToTF32Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { odsState.addOperands(src); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu)); } void ConvertFloatToTF32Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { odsState.addOperands(src); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.addTypes(res); } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { return create(builder, builder.getLoc(), std::forward(res), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu)); } void ConvertFloatToTF32Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { odsState.addOperands(src); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertFloatToTF32Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { return create(builder, builder.getLoc(), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu)); } void ConvertFloatToTF32Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { odsState.addOperands(src); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(rnd), std::forward(sat), std::forward(relu)); } void ConvertFloatToTF32Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertFloatToTF32Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertFloatToTF32Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ConvertFloatToTF32Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertFloatToTF32Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConvertFloatToTF32Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertFloatToTF32Op ConvertFloatToTF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertFloatToTF32Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.rnd) properties.rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), FPRoundingMode::NONE); if (!properties.sat) properties.sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertFloatToTF32Op::verifyInvariantsImpl() { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps11(*this, tblgen_rnd, "rnd"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps12(*this, tblgen_sat, "sat"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*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_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertFloatToTF32Op::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ConvertFloatToTF32Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ConvertFloatToTF32Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) 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(); } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); ::mlir::Type odsBuildableType1 = parser.getBuilder().getF32Type(); result.addTypes(odsBuildableType0); if (parser.resolveOperands(srcOperands, odsBuildableType1, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertFloatToTF32Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getRndAttr(); if(attr && (attr == ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), FPRoundingMode::NONE))) elidedAttrs.push_back("rnd"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getSatAttr(); if(attr && (attr == ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE))) elidedAttrs.push_back("sat"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertFloatToTF32Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertFloatToTF32OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ConvertS2F6x2ToBF16x2Op definitions //===----------------------------------------------------------------------===// namespace detail { ConvertS2F6x2ToBF16x2OpGenericAdaptorBase::ConvertS2F6x2ToBF16x2OpGenericAdaptorBase(ConvertS2F6x2ToBF16x2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ConvertS2F6x2ToBF16x2OpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::NVVM::SaturationModeAttr ConvertS2F6x2ToBF16x2OpGenericAdaptorBase::getSatAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::SaturationModeAttr>(getProperties().sat); return attr; } ::mlir::NVVM::SaturationMode ConvertS2F6x2ToBF16x2OpGenericAdaptorBase::getSat() { auto attr = getSatAttr(); return attr.getValue(); } ::mlir::BoolAttr ConvertS2F6x2ToBF16x2OpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool ConvertS2F6x2ToBF16x2OpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } } // namespace detail ConvertS2F6x2ToBF16x2OpAdaptor::ConvertS2F6x2ToBF16x2OpAdaptor(ConvertS2F6x2ToBF16x2Op op) : ConvertS2F6x2ToBF16x2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertS2F6x2ToBF16x2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (tblgen_sat && !((::llvm::isa<::mlir::NVVM::SaturationModeAttr>(tblgen_sat)))) return emitError(loc, "'nvvm.convert.s2f6x2.to.bf16x2' op attribute 'sat' failed to satisfy constraint: Describes the saturation mode"); if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.convert.s2f6x2.to.bf16x2' op attribute 'relu' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair ConvertS2F6x2ToBF16x2Op::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 ConvertS2F6x2ToBF16x2Op::getScaleFactorMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult ConvertS2F6x2ToBF16x2Op::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.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sat; auto attr = dict.get("sat"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sat` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertS2F6x2ToBF16x2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } { const auto &propStorage = prop.sat; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sat", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertS2F6x2ToBF16x2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relu.getAsOpaquePointer()), llvm::hash_value(prop.sat.getAsOpaquePointer())); } std::optional ConvertS2F6x2ToBF16x2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relu") return prop.relu; if (name == "sat") return prop.sat; return std::nullopt; } void ConvertS2F6x2ToBF16x2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sat") { prop.sat = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertS2F6x2ToBF16x2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relu) attrs.append("relu", prop.relu); if (prop.sat) attrs.append("sat", prop.sat); } ::llvm::LogicalResult ConvertS2F6x2ToBF16x2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSatAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps12(attr, "sat", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertS2F6x2ToBF16x2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.sat))) return ::mlir::failure(); return ::mlir::success(); } void ConvertS2F6x2ToBF16x2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relu); writer.writeOptionalAttribute(prop.sat); } ::mlir::NVVM::SaturationMode ConvertS2F6x2ToBF16x2Op::getSat() { auto attr = getSatAttr(); return attr.getValue(); } bool ConvertS2F6x2ToBF16x2Op::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } void ConvertS2F6x2ToBF16x2Op::setSat(::mlir::NVVM::SaturationMode attrValue) { getProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ConvertS2F6x2ToBF16x2Op::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ConvertS2F6x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } odsState.addTypes(dst); } ConvertS2F6x2ToBF16x2Op ConvertS2F6x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertS2F6x2ToBF16x2Op ConvertS2F6x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(sat), std::forward(relu)); } void ConvertS2F6x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); if (sat) { odsState.getOrAddProperties().sat = sat; } if (relu) { odsState.getOrAddProperties().relu = relu; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertS2F6x2ToBF16x2Op ConvertS2F6x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertS2F6x2ToBF16x2Op ConvertS2F6x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(sat), std::forward(relu)); } void ConvertS2F6x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::NVVM::SaturationMode sat, bool relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.addTypes(dst); } ConvertS2F6x2ToBF16x2Op ConvertS2F6x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::NVVM::SaturationMode sat, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertS2F6x2ToBF16x2Op ConvertS2F6x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::NVVM::SaturationMode sat, bool relu) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(scaleFactor), std::forward(sat), std::forward(relu)); } void ConvertS2F6x2ToBF16x2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::NVVM::SaturationMode sat, bool relu) { odsState.addOperands(src); if (scaleFactor) odsState.addOperands(scaleFactor); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertS2F6x2ToBF16x2Op ConvertS2F6x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::NVVM::SaturationMode sat, bool relu) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(sat), std::forward(relu)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertS2F6x2ToBF16x2Op ConvertS2F6x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, /*optional*/::mlir::Value scaleFactor, ::mlir::NVVM::SaturationMode sat, bool relu) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(scaleFactor), std::forward(sat), std::forward(relu)); } void ConvertS2F6x2ToBF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ConvertS2F6x2ToBF16x2Op ConvertS2F6x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertS2F6x2ToBF16x2Op ConvertS2F6x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ConvertS2F6x2ToBF16x2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ConvertS2F6x2ToBF16x2Op ConvertS2F6x2ToBF16x2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertS2F6x2ToBF16x2Op ConvertS2F6x2ToBF16x2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ConvertS2F6x2ToBF16x2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.sat) properties.sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ConvertS2F6x2ToBF16x2Op::verifyInvariantsImpl() { auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps12(*this, tblgen_sat, "sat"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps16(*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_NVVMOps11(*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_NVVMOps8(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ConvertS2F6x2ToBF16x2Op::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ConvertS2F6x2ToBF16x2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> scaleFactorOperands; ::llvm::SMLoc scaleFactorOperandsLoc; (void)scaleFactorOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::Type dstRawType{}; ::llvm::ArrayRef<::mlir::Type> dstTypes(&dstRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { scaleFactorOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); scaleFactorOperands.push_back(operand); } } } { 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(16); result.addTypes(dstTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); if (!scaleFactorOperands.empty()) { if (parser.resolveOperands(scaleFactorOperands, odsBuildableType0, scaleFactorOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void ConvertS2F6x2ToBF16x2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); if (getScaleFactor()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getScaleFactor()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getSatAttr(); if(attr && (attr == ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE))) elidedAttrs.push_back("sat"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getDst().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ConvertS2F6x2ToBF16x2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ConvertS2F6x2ToBF16x2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::CosOp definitions //===----------------------------------------------------------------------===// namespace detail { CosOpGenericAdaptorBase::CosOpGenericAdaptorBase(CosOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::BoolAttr CosOpGenericAdaptorBase::getFtzAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().ftz); return attr; } bool CosOpGenericAdaptorBase::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } } // namespace detail CosOpAdaptor::CosOpAdaptor(CosOp op) : CosOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CosOpAdaptor::verify(::mlir::Location loc) { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; if (tblgen_ftz && !((::llvm::isa<::mlir::BoolAttr>(tblgen_ftz)))) return emitError(loc, "'nvvm.cos' op attribute 'ftz' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult CosOp::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.ftz; auto attr = dict.get("ftz"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ftz` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute CosOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.ftz; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ftz", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code CosOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.ftz.getAsOpaquePointer())); } std::optional CosOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "ftz") return prop.ftz; return std::nullopt; } void CosOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "ftz") { prop.ftz = ::llvm::dyn_cast_or_null>(value); return; } } void CosOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.ftz) attrs.append("ftz", prop.ftz); } ::llvm::LogicalResult CosOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFtzAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "ftz", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult CosOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.ftz))) return ::mlir::failure(); return ::mlir::success(); } void CosOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.ftz); } bool CosOp::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } void CosOp::setFtz(bool attrValue) { getProperties().ftz = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void CosOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } odsState.addTypes(res); } CosOp CosOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CosOp CosOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(src), std::forward(ftz)); } void CosOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(CosOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } CosOp CosOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CosOp CosOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(src), std::forward(ftz)); } void CosOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } CosOp CosOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CosOp CosOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(ftz)); } void CosOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); odsState.addTypes(res); } CosOp CosOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CosOp CosOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(src), std::forward(ftz)); } void CosOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(CosOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } CosOp CosOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CosOp CosOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(src), std::forward(ftz)); } void CosOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } CosOp CosOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CosOp CosOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(ftz)); } void CosOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } CosOp CosOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CosOp CosOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CosOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(CosOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } CosOp CosOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CosOp CosOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void CosOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CosOp CosOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CosOp CosOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void CosOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(CosOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } CosOp CosOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CosOp CosOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void CosOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.ftz) properties.ftz = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult CosOp::verifyInvariantsImpl() { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_ftz, "ftz"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*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_NVVMOps13(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CosOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult CosOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); if (operands.size() <= 0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[0].getType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult CosOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) 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::FloatType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } result.addTypes(srcTypes[0]); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void CosOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFtzAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("ftz"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::FloatType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void CosOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::CosOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::CosOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::CpAsyncBulkCommitGroupOp definitions //===----------------------------------------------------------------------===// namespace detail { CpAsyncBulkCommitGroupOpGenericAdaptorBase::CpAsyncBulkCommitGroupOpGenericAdaptorBase(CpAsyncBulkCommitGroupOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail CpAsyncBulkCommitGroupOpAdaptor::CpAsyncBulkCommitGroupOpAdaptor(CpAsyncBulkCommitGroupOp op) : CpAsyncBulkCommitGroupOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CpAsyncBulkCommitGroupOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkCommitGroupOp::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 CpAsyncBulkCommitGroupOp::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 CpAsyncBulkCommitGroupOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional CpAsyncBulkCommitGroupOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void CpAsyncBulkCommitGroupOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void CpAsyncBulkCommitGroupOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult CpAsyncBulkCommitGroupOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void CpAsyncBulkCommitGroupOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { } CpAsyncBulkCommitGroupOp CpAsyncBulkCommitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkCommitGroupOp CpAsyncBulkCommitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void CpAsyncBulkCommitGroupOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncBulkCommitGroupOp CpAsyncBulkCommitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkCommitGroupOp CpAsyncBulkCommitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void CpAsyncBulkCommitGroupOp::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); } CpAsyncBulkCommitGroupOp CpAsyncBulkCommitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkCommitGroupOp CpAsyncBulkCommitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CpAsyncBulkCommitGroupOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CpAsyncBulkCommitGroupOp CpAsyncBulkCommitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkCommitGroupOp CpAsyncBulkCommitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult CpAsyncBulkCommitGroupOp::verifyInvariantsImpl() { return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkCommitGroupOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult CpAsyncBulkCommitGroupOp::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 CpAsyncBulkCommitGroupOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::CpAsyncBulkCommitGroupOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::CpAsyncBulkGlobalToSharedClusterOp definitions //===----------------------------------------------------------------------===// namespace detail { CpAsyncBulkGlobalToSharedClusterOpGenericAdaptorBase::CpAsyncBulkGlobalToSharedClusterOpGenericAdaptorBase(CpAsyncBulkGlobalToSharedClusterOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair CpAsyncBulkGlobalToSharedClusterOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } } // namespace detail CpAsyncBulkGlobalToSharedClusterOpAdaptor::CpAsyncBulkGlobalToSharedClusterOpAdaptor(CpAsyncBulkGlobalToSharedClusterOp op) : CpAsyncBulkGlobalToSharedClusterOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CpAsyncBulkGlobalToSharedClusterOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair CpAsyncBulkGlobalToSharedClusterOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange CpAsyncBulkGlobalToSharedClusterOp::getMulticastMaskMutable() { 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 CpAsyncBulkGlobalToSharedClusterOp::getL2CacheHintMutable() { 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 CpAsyncBulkGlobalToSharedClusterOp::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 CpAsyncBulkGlobalToSharedClusterOp::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 CpAsyncBulkGlobalToSharedClusterOp::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 CpAsyncBulkGlobalToSharedClusterOp::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 CpAsyncBulkGlobalToSharedClusterOp::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 CpAsyncBulkGlobalToSharedClusterOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult CpAsyncBulkGlobalToSharedClusterOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkGlobalToSharedClusterOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void CpAsyncBulkGlobalToSharedClusterOp::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 CpAsyncBulkGlobalToSharedClusterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value mbar, ::mlir::Value size, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint) { odsState.addOperands(dstMem); odsState.addOperands(srcMem); odsState.addOperands(mbar); odsState.addOperands(size); if (multicastMask) odsState.addOperands(multicastMask); if (l2CacheHint) odsState.addOperands(l2CacheHint); ::llvm::copy(::llvm::ArrayRef({1, 1, 1, 1, (multicastMask ? 1 : 0), (l2CacheHint ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); } CpAsyncBulkGlobalToSharedClusterOp CpAsyncBulkGlobalToSharedClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value mbar, ::mlir::Value size, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dstMem), std::forward(srcMem), std::forward(mbar), std::forward(size), std::forward(multicastMask), std::forward(l2CacheHint)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkGlobalToSharedClusterOp CpAsyncBulkGlobalToSharedClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value mbar, ::mlir::Value size, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint) { return create(builder, builder.getLoc(), std::forward(dstMem), std::forward(srcMem), std::forward(mbar), std::forward(size), std::forward(multicastMask), std::forward(l2CacheHint)); } void CpAsyncBulkGlobalToSharedClusterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value mbar, ::mlir::Value size, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint) { odsState.addOperands(dstMem); odsState.addOperands(srcMem); odsState.addOperands(mbar); odsState.addOperands(size); if (multicastMask) odsState.addOperands(multicastMask); if (l2CacheHint) odsState.addOperands(l2CacheHint); ::llvm::copy(::llvm::ArrayRef({1, 1, 1, 1, (multicastMask ? 1 : 0), (l2CacheHint ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncBulkGlobalToSharedClusterOp CpAsyncBulkGlobalToSharedClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value mbar, ::mlir::Value size, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(dstMem), std::forward(srcMem), std::forward(mbar), std::forward(size), std::forward(multicastMask), std::forward(l2CacheHint)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkGlobalToSharedClusterOp CpAsyncBulkGlobalToSharedClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value mbar, ::mlir::Value size, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(dstMem), std::forward(srcMem), std::forward(mbar), std::forward(size), std::forward(multicastMask), std::forward(l2CacheHint)); } void CpAsyncBulkGlobalToSharedClusterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 4u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } CpAsyncBulkGlobalToSharedClusterOp CpAsyncBulkGlobalToSharedClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkGlobalToSharedClusterOp CpAsyncBulkGlobalToSharedClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CpAsyncBulkGlobalToSharedClusterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 4u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CpAsyncBulkGlobalToSharedClusterOp CpAsyncBulkGlobalToSharedClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkGlobalToSharedClusterOp CpAsyncBulkGlobalToSharedClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult CpAsyncBulkGlobalToSharedClusterOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps17(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps18(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps11(*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_NVVMOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkGlobalToSharedClusterOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult CpAsyncBulkGlobalToSharedClusterOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand dstMemRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> dstMemOperands(&dstMemRawOperand, 1); ::llvm::SMLoc dstMemOperandsLoc; (void)dstMemOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand srcMemRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcMemOperands(&srcMemRawOperand, 1); ::llvm::SMLoc srcMemOperandsLoc; (void)srcMemOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand mbarRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> mbarOperands(&mbarRawOperand, 1); ::llvm::SMLoc mbarOperandsLoc; (void)mbarOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand sizeRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sizeOperands(&sizeRawOperand, 1); ::llvm::SMLoc sizeOperandsLoc; (void)sizeOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> multicastMaskOperands; ::llvm::SMLoc multicastMaskOperandsLoc; (void)multicastMaskOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> l2CacheHintOperands; ::llvm::SMLoc l2CacheHintOperandsLoc; (void)l2CacheHintOperandsLoc; ::mlir::Type dstMemRawType{}; ::llvm::ArrayRef<::mlir::Type> dstMemTypes(&dstMemRawType, 1); ::mlir::Type srcMemRawType{}; ::llvm::ArrayRef<::mlir::Type> srcMemTypes(&srcMemRawType, 1); dstMemOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(dstMemRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); srcMemOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcMemRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); mbarOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(mbarRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); sizeOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sizeRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("multicast_mask"))) { if (parser.parseEqual()) return ::mlir::failure(); { multicastMaskOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); multicastMaskOperands.push_back(operand); } } } if (::mlir::succeeded(parser.parseOptionalKeyword("l2_cache_hint"))) { if (parser.parseEqual()) return ::mlir::failure(); { l2CacheHintOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); l2CacheHintOperands.push_back(operand); } } } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstMemRawType = type; } if (parser.parseComma()) return ::mlir::failure(); { ::mlir::LLVM::LLVMPointerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcMemRawType = type; } ::llvm::copy(::llvm::ArrayRef({1, 1, 1, 1, static_cast(multicastMaskOperands.size()), static_cast(l2CacheHintOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::LLVM::LLVMPointerType>(3); ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(32); ::mlir::Type odsBuildableType2 = parser.getBuilder().getIntegerType(16); ::mlir::Type odsBuildableType3 = parser.getBuilder().getIntegerType(64); if (parser.resolveOperands(dstMemOperands, dstMemTypes, dstMemOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(srcMemOperands, srcMemTypes, srcMemOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(mbarOperands, odsBuildableType0, mbarOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(sizeOperands, odsBuildableType1, sizeOperandsLoc, result.operands)) return ::mlir::failure(); if (!multicastMaskOperands.empty()) { if (parser.resolveOperands(multicastMaskOperands, odsBuildableType2, multicastMaskOperandsLoc, result.operands)) return ::mlir::failure(); } if (!l2CacheHintOperands.empty()) { if (parser.resolveOperands(l2CacheHintOperands, odsBuildableType3, l2CacheHintOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void CpAsyncBulkGlobalToSharedClusterOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getDstMem(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSrcMem(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMbar(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSize(); if (getMulticastMask()) { _odsPrinter << ' ' << "multicast_mask"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getMulticastMask()) _odsPrinter << value; } if (getL2CacheHint()) { _odsPrinter << ' ' << "l2_cache_hint"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getL2CacheHint()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getDstMem().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; { auto type = getSrcMem().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::LLVM::LLVMPointerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::CpAsyncBulkGlobalToSharedClusterOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::CpAsyncBulkGlobalToSharedClusterOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::CpAsyncBulkPrefetchOp definitions //===----------------------------------------------------------------------===// namespace detail { CpAsyncBulkPrefetchOpGenericAdaptorBase::CpAsyncBulkPrefetchOpGenericAdaptorBase(CpAsyncBulkPrefetchOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair CpAsyncBulkPrefetchOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } } // namespace detail CpAsyncBulkPrefetchOpAdaptor::CpAsyncBulkPrefetchOpAdaptor(CpAsyncBulkPrefetchOp op) : CpAsyncBulkPrefetchOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CpAsyncBulkPrefetchOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair CpAsyncBulkPrefetchOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange CpAsyncBulkPrefetchOp::getL2CacheHintMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult CpAsyncBulkPrefetchOp::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 CpAsyncBulkPrefetchOp::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 CpAsyncBulkPrefetchOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional CpAsyncBulkPrefetchOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void CpAsyncBulkPrefetchOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void CpAsyncBulkPrefetchOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult CpAsyncBulkPrefetchOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void CpAsyncBulkPrefetchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value srcMem, ::mlir::Value size, /*optional*/::mlir::Value l2CacheHint) { odsState.addOperands(srcMem); odsState.addOperands(size); if (l2CacheHint) odsState.addOperands(l2CacheHint); } CpAsyncBulkPrefetchOp CpAsyncBulkPrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value srcMem, ::mlir::Value size, /*optional*/::mlir::Value l2CacheHint) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(srcMem), std::forward(size), std::forward(l2CacheHint)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkPrefetchOp CpAsyncBulkPrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value srcMem, ::mlir::Value size, /*optional*/::mlir::Value l2CacheHint) { return create(builder, builder.getLoc(), std::forward(srcMem), std::forward(size), std::forward(l2CacheHint)); } void CpAsyncBulkPrefetchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value srcMem, ::mlir::Value size, /*optional*/::mlir::Value l2CacheHint) { odsState.addOperands(srcMem); odsState.addOperands(size); if (l2CacheHint) odsState.addOperands(l2CacheHint); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncBulkPrefetchOp CpAsyncBulkPrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value srcMem, ::mlir::Value size, /*optional*/::mlir::Value l2CacheHint) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(srcMem), std::forward(size), std::forward(l2CacheHint)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkPrefetchOp CpAsyncBulkPrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value srcMem, ::mlir::Value size, /*optional*/::mlir::Value l2CacheHint) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(srcMem), std::forward(size), std::forward(l2CacheHint)); } void CpAsyncBulkPrefetchOp::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); } CpAsyncBulkPrefetchOp CpAsyncBulkPrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkPrefetchOp CpAsyncBulkPrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CpAsyncBulkPrefetchOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CpAsyncBulkPrefetchOp CpAsyncBulkPrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkPrefetchOp CpAsyncBulkPrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult CpAsyncBulkPrefetchOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps18(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkPrefetchOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult CpAsyncBulkPrefetchOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcMemRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcMemOperands(&srcMemRawOperand, 1); ::llvm::SMLoc srcMemOperandsLoc; (void)srcMemOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand sizeRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sizeOperands(&sizeRawOperand, 1); ::llvm::SMLoc sizeOperandsLoc; (void)sizeOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> l2CacheHintOperands; ::llvm::SMLoc l2CacheHintOperandsLoc; (void)l2CacheHintOperandsLoc; ::mlir::Type srcMemRawType{}; ::llvm::ArrayRef<::mlir::Type> srcMemTypes(&srcMemRawType, 1); srcMemOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcMemRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); sizeOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sizeRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("l2_cache_hint"))) { if (parser.parseEqual()) return ::mlir::failure(); { l2CacheHintOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); l2CacheHintOperands.push_back(operand); } } } { 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::LLVM::LLVMPointerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcMemRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(64); if (parser.resolveOperands(srcMemOperands, srcMemTypes, srcMemOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(sizeOperands, odsBuildableType0, sizeOperandsLoc, result.operands)) return ::mlir::failure(); if (!l2CacheHintOperands.empty()) { if (parser.resolveOperands(l2CacheHintOperands, odsBuildableType1, l2CacheHintOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void CpAsyncBulkPrefetchOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrcMem(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSize(); if (getL2CacheHint()) { _odsPrinter << ' ' << "l2_cache_hint"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getL2CacheHint()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrcMem().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::LLVM::LLVMPointerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::CpAsyncBulkPrefetchOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::CpAsyncBulkSharedCTAToGlobalOp definitions //===----------------------------------------------------------------------===// namespace detail { CpAsyncBulkSharedCTAToGlobalOpGenericAdaptorBase::CpAsyncBulkSharedCTAToGlobalOpGenericAdaptorBase(CpAsyncBulkSharedCTAToGlobalOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair CpAsyncBulkSharedCTAToGlobalOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } } // namespace detail CpAsyncBulkSharedCTAToGlobalOpAdaptor::CpAsyncBulkSharedCTAToGlobalOpAdaptor(CpAsyncBulkSharedCTAToGlobalOp op) : CpAsyncBulkSharedCTAToGlobalOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CpAsyncBulkSharedCTAToGlobalOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair CpAsyncBulkSharedCTAToGlobalOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange CpAsyncBulkSharedCTAToGlobalOp::getL2CacheHintMutable() { 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 CpAsyncBulkSharedCTAToGlobalOp::getByteMaskMutable() { 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 CpAsyncBulkSharedCTAToGlobalOp::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 CpAsyncBulkSharedCTAToGlobalOp::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 CpAsyncBulkSharedCTAToGlobalOp::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 CpAsyncBulkSharedCTAToGlobalOp::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 CpAsyncBulkSharedCTAToGlobalOp::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 CpAsyncBulkSharedCTAToGlobalOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult CpAsyncBulkSharedCTAToGlobalOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkSharedCTAToGlobalOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void CpAsyncBulkSharedCTAToGlobalOp::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 CpAsyncBulkSharedCTAToGlobalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value size, /*optional*/::mlir::Value l2CacheHint, /*optional*/::mlir::Value byteMask) { odsState.addOperands(dstMem); odsState.addOperands(srcMem); odsState.addOperands(size); if (l2CacheHint) odsState.addOperands(l2CacheHint); if (byteMask) odsState.addOperands(byteMask); ::llvm::copy(::llvm::ArrayRef({1, 1, 1, (l2CacheHint ? 1 : 0), (byteMask ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); } CpAsyncBulkSharedCTAToGlobalOp CpAsyncBulkSharedCTAToGlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value size, /*optional*/::mlir::Value l2CacheHint, /*optional*/::mlir::Value byteMask) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dstMem), std::forward(srcMem), std::forward(size), std::forward(l2CacheHint), std::forward(byteMask)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkSharedCTAToGlobalOp CpAsyncBulkSharedCTAToGlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value size, /*optional*/::mlir::Value l2CacheHint, /*optional*/::mlir::Value byteMask) { return create(builder, builder.getLoc(), std::forward(dstMem), std::forward(srcMem), std::forward(size), std::forward(l2CacheHint), std::forward(byteMask)); } void CpAsyncBulkSharedCTAToGlobalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value size, /*optional*/::mlir::Value l2CacheHint, /*optional*/::mlir::Value byteMask) { odsState.addOperands(dstMem); odsState.addOperands(srcMem); odsState.addOperands(size); if (l2CacheHint) odsState.addOperands(l2CacheHint); if (byteMask) odsState.addOperands(byteMask); ::llvm::copy(::llvm::ArrayRef({1, 1, 1, (l2CacheHint ? 1 : 0), (byteMask ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncBulkSharedCTAToGlobalOp CpAsyncBulkSharedCTAToGlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value size, /*optional*/::mlir::Value l2CacheHint, /*optional*/::mlir::Value byteMask) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(dstMem), std::forward(srcMem), std::forward(size), std::forward(l2CacheHint), std::forward(byteMask)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkSharedCTAToGlobalOp CpAsyncBulkSharedCTAToGlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value size, /*optional*/::mlir::Value l2CacheHint, /*optional*/::mlir::Value byteMask) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(dstMem), std::forward(srcMem), std::forward(size), std::forward(l2CacheHint), std::forward(byteMask)); } void CpAsyncBulkSharedCTAToGlobalOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } CpAsyncBulkSharedCTAToGlobalOp CpAsyncBulkSharedCTAToGlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkSharedCTAToGlobalOp CpAsyncBulkSharedCTAToGlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CpAsyncBulkSharedCTAToGlobalOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CpAsyncBulkSharedCTAToGlobalOp CpAsyncBulkSharedCTAToGlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkSharedCTAToGlobalOp CpAsyncBulkSharedCTAToGlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult CpAsyncBulkSharedCTAToGlobalOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps18(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps4(*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_NVVMOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkSharedCTAToGlobalOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult CpAsyncBulkSharedCTAToGlobalOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand dstMemRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> dstMemOperands(&dstMemRawOperand, 1); ::llvm::SMLoc dstMemOperandsLoc; (void)dstMemOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand srcMemRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcMemOperands(&srcMemRawOperand, 1); ::llvm::SMLoc srcMemOperandsLoc; (void)srcMemOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand sizeRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sizeOperands(&sizeRawOperand, 1); ::llvm::SMLoc sizeOperandsLoc; (void)sizeOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> l2CacheHintOperands; ::llvm::SMLoc l2CacheHintOperandsLoc; (void)l2CacheHintOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> byteMaskOperands; ::llvm::SMLoc byteMaskOperandsLoc; (void)byteMaskOperandsLoc; ::mlir::Type dstMemRawType{}; ::llvm::ArrayRef<::mlir::Type> dstMemTypes(&dstMemRawType, 1); ::mlir::Type srcMemRawType{}; ::llvm::ArrayRef<::mlir::Type> srcMemTypes(&srcMemRawType, 1); dstMemOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(dstMemRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); srcMemOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcMemRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); sizeOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sizeRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("l2_cache_hint"))) { if (parser.parseEqual()) return ::mlir::failure(); { l2CacheHintOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); l2CacheHintOperands.push_back(operand); } } } if (::mlir::succeeded(parser.parseOptionalKeyword("byte_mask"))) { if (parser.parseEqual()) return ::mlir::failure(); { byteMaskOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); byteMaskOperands.push_back(operand); } } } { 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::LLVM::LLVMPointerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstMemRawType = type; } if (parser.parseComma()) return ::mlir::failure(); { ::mlir::LLVM::LLVMPointerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcMemRawType = type; } ::llvm::copy(::llvm::ArrayRef({1, 1, 1, static_cast(l2CacheHintOperands.size()), static_cast(byteMaskOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(64); ::mlir::Type odsBuildableType2 = parser.getBuilder().getIntegerType(16); if (parser.resolveOperands(dstMemOperands, dstMemTypes, dstMemOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(srcMemOperands, srcMemTypes, srcMemOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(sizeOperands, odsBuildableType0, sizeOperandsLoc, result.operands)) return ::mlir::failure(); if (!l2CacheHintOperands.empty()) { if (parser.resolveOperands(l2CacheHintOperands, odsBuildableType1, l2CacheHintOperandsLoc, result.operands)) return ::mlir::failure(); } if (!byteMaskOperands.empty()) { if (parser.resolveOperands(byteMaskOperands, odsBuildableType2, byteMaskOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void CpAsyncBulkSharedCTAToGlobalOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getDstMem(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSrcMem(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSize(); if (getL2CacheHint()) { _odsPrinter << ' ' << "l2_cache_hint"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getL2CacheHint()) _odsPrinter << value; } if (getByteMask()) { _odsPrinter << ' ' << "byte_mask"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getByteMask()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getDstMem().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::LLVM::LLVMPointerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; { auto type = getSrcMem().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::LLVM::LLVMPointerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::CpAsyncBulkSharedCTAToGlobalOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::CpAsyncBulkSharedCTAToGlobalOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::CpAsyncBulkSharedCTAToSharedClusterOp definitions //===----------------------------------------------------------------------===// namespace detail { CpAsyncBulkSharedCTAToSharedClusterOpGenericAdaptorBase::CpAsyncBulkSharedCTAToSharedClusterOpGenericAdaptorBase(CpAsyncBulkSharedCTAToSharedClusterOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail CpAsyncBulkSharedCTAToSharedClusterOpAdaptor::CpAsyncBulkSharedCTAToSharedClusterOpAdaptor(CpAsyncBulkSharedCTAToSharedClusterOp op) : CpAsyncBulkSharedCTAToSharedClusterOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CpAsyncBulkSharedCTAToSharedClusterOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkSharedCTAToSharedClusterOp::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 CpAsyncBulkSharedCTAToSharedClusterOp::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 CpAsyncBulkSharedCTAToSharedClusterOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional CpAsyncBulkSharedCTAToSharedClusterOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void CpAsyncBulkSharedCTAToSharedClusterOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void CpAsyncBulkSharedCTAToSharedClusterOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult CpAsyncBulkSharedCTAToSharedClusterOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void CpAsyncBulkSharedCTAToSharedClusterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value mbar, ::mlir::Value size) { odsState.addOperands(dstMem); odsState.addOperands(srcMem); odsState.addOperands(mbar); odsState.addOperands(size); } CpAsyncBulkSharedCTAToSharedClusterOp CpAsyncBulkSharedCTAToSharedClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value mbar, ::mlir::Value size) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dstMem), std::forward(srcMem), std::forward(mbar), std::forward(size)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkSharedCTAToSharedClusterOp CpAsyncBulkSharedCTAToSharedClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value mbar, ::mlir::Value size) { return create(builder, builder.getLoc(), std::forward(dstMem), std::forward(srcMem), std::forward(mbar), std::forward(size)); } void CpAsyncBulkSharedCTAToSharedClusterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value mbar, ::mlir::Value size) { odsState.addOperands(dstMem); odsState.addOperands(srcMem); odsState.addOperands(mbar); odsState.addOperands(size); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncBulkSharedCTAToSharedClusterOp CpAsyncBulkSharedCTAToSharedClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value mbar, ::mlir::Value size) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(dstMem), std::forward(srcMem), std::forward(mbar), std::forward(size)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkSharedCTAToSharedClusterOp CpAsyncBulkSharedCTAToSharedClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value dstMem, ::mlir::Value srcMem, ::mlir::Value mbar, ::mlir::Value size) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(dstMem), std::forward(srcMem), std::forward(mbar), std::forward(size)); } void CpAsyncBulkSharedCTAToSharedClusterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 4u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CpAsyncBulkSharedCTAToSharedClusterOp CpAsyncBulkSharedCTAToSharedClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkSharedCTAToSharedClusterOp CpAsyncBulkSharedCTAToSharedClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CpAsyncBulkSharedCTAToSharedClusterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 4u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CpAsyncBulkSharedCTAToSharedClusterOp CpAsyncBulkSharedCTAToSharedClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkSharedCTAToSharedClusterOp CpAsyncBulkSharedCTAToSharedClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult CpAsyncBulkSharedCTAToSharedClusterOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps19(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkSharedCTAToSharedClusterOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult CpAsyncBulkSharedCTAToSharedClusterOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand dstMemRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> dstMemOperands(&dstMemRawOperand, 1); ::llvm::SMLoc dstMemOperandsLoc; (void)dstMemOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand srcMemRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcMemOperands(&srcMemRawOperand, 1); ::llvm::SMLoc srcMemOperandsLoc; (void)srcMemOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand mbarRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> mbarOperands(&mbarRawOperand, 1); ::llvm::SMLoc mbarOperandsLoc; (void)mbarOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand sizeRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sizeOperands(&sizeRawOperand, 1); ::llvm::SMLoc sizeOperandsLoc; (void)sizeOperandsLoc; ::mlir::Type dstMemRawType{}; ::llvm::ArrayRef<::mlir::Type> dstMemTypes(&dstMemRawType, 1); ::mlir::Type srcMemRawType{}; ::llvm::ArrayRef<::mlir::Type> srcMemTypes(&srcMemRawType, 1); dstMemOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(dstMemRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); srcMemOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcMemRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); mbarOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(mbarRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); sizeOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sizeRawOperand)) 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::LLVM::LLVMPointerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstMemRawType = type; } if (parser.parseComma()) return ::mlir::failure(); { ::mlir::LLVM::LLVMPointerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcMemRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::LLVM::LLVMPointerType>(3); ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(32); if (parser.resolveOperands(dstMemOperands, dstMemTypes, dstMemOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(srcMemOperands, srcMemTypes, srcMemOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(mbarOperands, odsBuildableType0, mbarOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(sizeOperands, odsBuildableType1, sizeOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void CpAsyncBulkSharedCTAToSharedClusterOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getDstMem(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSrcMem(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMbar(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSize(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getDstMem().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::LLVM::LLVMPointerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; { auto type = getSrcMem().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::LLVM::LLVMPointerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::CpAsyncBulkSharedCTAToSharedClusterOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::CpAsyncBulkTensorGlobalToSharedClusterOp definitions //===----------------------------------------------------------------------===// namespace detail { CpAsyncBulkTensorGlobalToSharedClusterOpGenericAdaptorBase::CpAsyncBulkTensorGlobalToSharedClusterOpGenericAdaptorBase(CpAsyncBulkTensorGlobalToSharedClusterOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair CpAsyncBulkTensorGlobalToSharedClusterOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::NVVM::TMALoadModeAttr CpAsyncBulkTensorGlobalToSharedClusterOpGenericAdaptorBase::getModeAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::TMALoadModeAttr>(getProperties().mode); return attr; } ::mlir::NVVM::TMALoadMode CpAsyncBulkTensorGlobalToSharedClusterOpGenericAdaptorBase::getMode() { auto attr = getModeAttr(); return attr.getValue(); } ::mlir::BoolAttr CpAsyncBulkTensorGlobalToSharedClusterOpGenericAdaptorBase::getIsCTAOnlyAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().isCTAOnly); return attr; } bool CpAsyncBulkTensorGlobalToSharedClusterOpGenericAdaptorBase::getIsCTAOnly() { auto attr = getIsCTAOnlyAttr(); return attr.getValue(); } ::std::optional<::mlir::NVVM::CTAGroupKind> CpAsyncBulkTensorGlobalToSharedClusterOpGenericAdaptorBase::getGroup() { auto attr = getGroupAttr(); return attr ? ::std::optional<::mlir::NVVM::CTAGroupKind>(attr.getValue()) : (::std::nullopt); } } // namespace detail CpAsyncBulkTensorGlobalToSharedClusterOpAdaptor::CpAsyncBulkTensorGlobalToSharedClusterOpAdaptor(CpAsyncBulkTensorGlobalToSharedClusterOp op) : CpAsyncBulkTensorGlobalToSharedClusterOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CpAsyncBulkTensorGlobalToSharedClusterOpAdaptor::verify(::mlir::Location loc) { auto tblgen_group = getProperties().group; (void)tblgen_group; auto tblgen_isCTAOnly = getProperties().isCTAOnly; (void)tblgen_isCTAOnly; auto tblgen_mode = getProperties().mode; (void)tblgen_mode; if (tblgen_mode && !((::llvm::isa<::mlir::NVVM::TMALoadModeAttr>(tblgen_mode)))) return emitError(loc, "'nvvm.cp.async.bulk.tensor.shared.cluster.global' op attribute 'mode' failed to satisfy constraint: List of Load-Modes supported for TMA Tensor Ops"); if (tblgen_isCTAOnly && !((::llvm::isa<::mlir::BoolAttr>(tblgen_isCTAOnly)))) return emitError(loc, "'nvvm.cp.async.bulk.tensor.shared.cluster.global' op attribute 'isCTAOnly' failed to satisfy constraint: bool attribute"); if (tblgen_group && !((::llvm::isa<::mlir::NVVM::CTAGroupKindAttr>(tblgen_group)))) return emitError(loc, "'nvvm.cp.async.bulk.tensor.shared.cluster.global' op attribute 'group' failed to satisfy constraint: NVVM CTA group kind"); return ::mlir::success(); } std::pair CpAsyncBulkTensorGlobalToSharedClusterOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange CpAsyncBulkTensorGlobalToSharedClusterOp::getCoordinatesMutable() { 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 CpAsyncBulkTensorGlobalToSharedClusterOp::getIm2colOffsetsMutable() { 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 CpAsyncBulkTensorGlobalToSharedClusterOp::getMulticastMaskMutable() { 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 CpAsyncBulkTensorGlobalToSharedClusterOp::getL2CacheHintMutable() { 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 CpAsyncBulkTensorGlobalToSharedClusterOp::getPredicateMutable() { auto range = getODSOperandIndexAndLength(7); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(7u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult CpAsyncBulkTensorGlobalToSharedClusterOp::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.group; auto attr = dict.get("group"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `group` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.isCTAOnly; auto attr = dict.get("isCTAOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `isCTAOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.mode; auto attr = dict.get("mode"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `mode` 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 CpAsyncBulkTensorGlobalToSharedClusterOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.group; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("group", propStorage)); } { const auto &propStorage = prop.isCTAOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("isCTAOnly", propStorage)); } { const auto &propStorage = prop.mode; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("mode", 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 CpAsyncBulkTensorGlobalToSharedClusterOp::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.group.getAsOpaquePointer()), llvm::hash_value(prop.isCTAOnly.getAsOpaquePointer()), llvm::hash_value(prop.mode.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional CpAsyncBulkTensorGlobalToSharedClusterOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "group") return prop.group; if (name == "isCTAOnly") return prop.isCTAOnly; if (name == "mode") return prop.mode; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void CpAsyncBulkTensorGlobalToSharedClusterOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "group") { prop.group = ::llvm::dyn_cast_or_null>(value); return; } if (name == "isCTAOnly") { prop.isCTAOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "mode") { prop.mode = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void CpAsyncBulkTensorGlobalToSharedClusterOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.group) attrs.append("group", prop.group); if (prop.isCTAOnly) attrs.append("isCTAOnly", prop.isCTAOnly); if (prop.mode) attrs.append("mode", prop.mode); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult CpAsyncBulkTensorGlobalToSharedClusterOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getGroupAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(attr, "group", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getIsCTAOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "isCTAOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps18(attr, "mode", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkTensorGlobalToSharedClusterOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.group))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.isCTAOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.mode))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void CpAsyncBulkTensorGlobalToSharedClusterOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.group); writer.writeOptionalAttribute(prop.isCTAOnly); writer.writeOptionalAttribute(prop.mode); 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)); ; } } ::mlir::NVVM::TMALoadMode CpAsyncBulkTensorGlobalToSharedClusterOp::getMode() { auto attr = getModeAttr(); return attr.getValue(); } bool CpAsyncBulkTensorGlobalToSharedClusterOp::getIsCTAOnly() { auto attr = getIsCTAOnlyAttr(); return attr.getValue(); } ::std::optional<::mlir::NVVM::CTAGroupKind> CpAsyncBulkTensorGlobalToSharedClusterOp::getGroup() { auto attr = getGroupAttr(); return attr ? ::std::optional<::mlir::NVVM::CTAGroupKind>(attr.getValue()) : (::std::nullopt); } void CpAsyncBulkTensorGlobalToSharedClusterOp::setMode(::mlir::NVVM::TMALoadMode attrValue) { getProperties().mode = ::mlir::NVVM::TMALoadModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CpAsyncBulkTensorGlobalToSharedClusterOp::setIsCTAOnly(bool attrValue) { getProperties().isCTAOnly = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void CpAsyncBulkTensorGlobalToSharedClusterOp::setGroup(::std::optional<::mlir::NVVM::CTAGroupKind> attrValue) { auto &odsProp = getProperties().group; if (attrValue) odsProp = ::mlir::NVVM::CTAGroupKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void CpAsyncBulkTensorGlobalToSharedClusterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value dstMem, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::Value mbar, ::mlir::ValueRange im2colOffsets, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMALoadModeAttr mode, ::mlir::BoolAttr isCTAOnly, /*optional*/::mlir::NVVM::CTAGroupKindAttr group, /*optional*/::mlir::Value predicate) { odsState.addOperands(dstMem); odsState.addOperands(tmaDescriptor); odsState.addOperands(coordinates); odsState.addOperands(mbar); odsState.addOperands(im2colOffsets); if (multicastMask) odsState.addOperands(multicastMask); if (l2CacheHint) odsState.addOperands(l2CacheHint); if (predicate) odsState.addOperands(predicate); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(coordinates.size()), 1, static_cast(im2colOffsets.size()), (multicastMask ? 1 : 0), (l2CacheHint ? 1 : 0), (predicate ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (mode) { odsState.getOrAddProperties().mode = mode; } if (isCTAOnly) { odsState.getOrAddProperties().isCTAOnly = isCTAOnly; } if (group) { odsState.getOrAddProperties().group = group; } } CpAsyncBulkTensorGlobalToSharedClusterOp CpAsyncBulkTensorGlobalToSharedClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value dstMem, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::Value mbar, ::mlir::ValueRange im2colOffsets, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMALoadModeAttr mode, ::mlir::BoolAttr isCTAOnly, /*optional*/::mlir::NVVM::CTAGroupKindAttr group, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dstMem), std::forward(tmaDescriptor), std::forward(coordinates), std::forward(mbar), std::forward(im2colOffsets), std::forward(multicastMask), std::forward(l2CacheHint), std::forward(mode), std::forward(isCTAOnly), std::forward(group), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorGlobalToSharedClusterOp CpAsyncBulkTensorGlobalToSharedClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value dstMem, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::Value mbar, ::mlir::ValueRange im2colOffsets, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMALoadModeAttr mode, ::mlir::BoolAttr isCTAOnly, /*optional*/::mlir::NVVM::CTAGroupKindAttr group, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(dstMem), std::forward(tmaDescriptor), std::forward(coordinates), std::forward(mbar), std::forward(im2colOffsets), std::forward(multicastMask), std::forward(l2CacheHint), std::forward(mode), std::forward(isCTAOnly), std::forward(group), std::forward(predicate)); } void CpAsyncBulkTensorGlobalToSharedClusterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value dstMem, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::Value mbar, ::mlir::ValueRange im2colOffsets, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMALoadModeAttr mode, ::mlir::BoolAttr isCTAOnly, /*optional*/::mlir::NVVM::CTAGroupKindAttr group, /*optional*/::mlir::Value predicate) { odsState.addOperands(dstMem); odsState.addOperands(tmaDescriptor); odsState.addOperands(coordinates); odsState.addOperands(mbar); odsState.addOperands(im2colOffsets); if (multicastMask) odsState.addOperands(multicastMask); if (l2CacheHint) odsState.addOperands(l2CacheHint); if (predicate) odsState.addOperands(predicate); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(coordinates.size()), 1, static_cast(im2colOffsets.size()), (multicastMask ? 1 : 0), (l2CacheHint ? 1 : 0), (predicate ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (mode) { odsState.getOrAddProperties().mode = mode; } if (isCTAOnly) { odsState.getOrAddProperties().isCTAOnly = isCTAOnly; } if (group) { odsState.getOrAddProperties().group = group; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncBulkTensorGlobalToSharedClusterOp CpAsyncBulkTensorGlobalToSharedClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value dstMem, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::Value mbar, ::mlir::ValueRange im2colOffsets, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMALoadModeAttr mode, ::mlir::BoolAttr isCTAOnly, /*optional*/::mlir::NVVM::CTAGroupKindAttr group, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(dstMem), std::forward(tmaDescriptor), std::forward(coordinates), std::forward(mbar), std::forward(im2colOffsets), std::forward(multicastMask), std::forward(l2CacheHint), std::forward(mode), std::forward(isCTAOnly), std::forward(group), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorGlobalToSharedClusterOp CpAsyncBulkTensorGlobalToSharedClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value dstMem, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::Value mbar, ::mlir::ValueRange im2colOffsets, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMALoadModeAttr mode, ::mlir::BoolAttr isCTAOnly, /*optional*/::mlir::NVVM::CTAGroupKindAttr group, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(dstMem), std::forward(tmaDescriptor), std::forward(coordinates), std::forward(mbar), std::forward(im2colOffsets), std::forward(multicastMask), std::forward(l2CacheHint), std::forward(mode), std::forward(isCTAOnly), std::forward(group), std::forward(predicate)); } void CpAsyncBulkTensorGlobalToSharedClusterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value dstMem, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::Value mbar, ::mlir::ValueRange im2colOffsets, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMALoadMode mode, bool isCTAOnly, /*optional*/::mlir::NVVM::CTAGroupKindAttr group, /*optional*/::mlir::Value predicate) { odsState.addOperands(dstMem); odsState.addOperands(tmaDescriptor); odsState.addOperands(coordinates); odsState.addOperands(mbar); odsState.addOperands(im2colOffsets); if (multicastMask) odsState.addOperands(multicastMask); if (l2CacheHint) odsState.addOperands(l2CacheHint); if (predicate) odsState.addOperands(predicate); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(coordinates.size()), 1, static_cast(im2colOffsets.size()), (multicastMask ? 1 : 0), (l2CacheHint ? 1 : 0), (predicate ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().mode = ::mlir::NVVM::TMALoadModeAttr::get(odsBuilder.getContext(), mode); odsState.getOrAddProperties().isCTAOnly = odsBuilder.getBoolAttr(isCTAOnly); if (group) { odsState.getOrAddProperties().group = group; } } CpAsyncBulkTensorGlobalToSharedClusterOp CpAsyncBulkTensorGlobalToSharedClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value dstMem, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::Value mbar, ::mlir::ValueRange im2colOffsets, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMALoadMode mode, bool isCTAOnly, /*optional*/::mlir::NVVM::CTAGroupKindAttr group, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dstMem), std::forward(tmaDescriptor), std::forward(coordinates), std::forward(mbar), std::forward(im2colOffsets), std::forward(multicastMask), std::forward(l2CacheHint), std::forward(mode), std::forward(isCTAOnly), std::forward(group), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorGlobalToSharedClusterOp CpAsyncBulkTensorGlobalToSharedClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value dstMem, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::Value mbar, ::mlir::ValueRange im2colOffsets, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMALoadMode mode, bool isCTAOnly, /*optional*/::mlir::NVVM::CTAGroupKindAttr group, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(dstMem), std::forward(tmaDescriptor), std::forward(coordinates), std::forward(mbar), std::forward(im2colOffsets), std::forward(multicastMask), std::forward(l2CacheHint), std::forward(mode), std::forward(isCTAOnly), std::forward(group), std::forward(predicate)); } void CpAsyncBulkTensorGlobalToSharedClusterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value dstMem, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::Value mbar, ::mlir::ValueRange im2colOffsets, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMALoadMode mode, bool isCTAOnly, /*optional*/::mlir::NVVM::CTAGroupKindAttr group, /*optional*/::mlir::Value predicate) { odsState.addOperands(dstMem); odsState.addOperands(tmaDescriptor); odsState.addOperands(coordinates); odsState.addOperands(mbar); odsState.addOperands(im2colOffsets); if (multicastMask) odsState.addOperands(multicastMask); if (l2CacheHint) odsState.addOperands(l2CacheHint); if (predicate) odsState.addOperands(predicate); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(coordinates.size()), 1, static_cast(im2colOffsets.size()), (multicastMask ? 1 : 0), (l2CacheHint ? 1 : 0), (predicate ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().mode = ::mlir::NVVM::TMALoadModeAttr::get(odsBuilder.getContext(), mode); odsState.getOrAddProperties().isCTAOnly = odsBuilder.getBoolAttr(isCTAOnly); if (group) { odsState.getOrAddProperties().group = group; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncBulkTensorGlobalToSharedClusterOp CpAsyncBulkTensorGlobalToSharedClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value dstMem, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::Value mbar, ::mlir::ValueRange im2colOffsets, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMALoadMode mode, bool isCTAOnly, /*optional*/::mlir::NVVM::CTAGroupKindAttr group, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(dstMem), std::forward(tmaDescriptor), std::forward(coordinates), std::forward(mbar), std::forward(im2colOffsets), std::forward(multicastMask), std::forward(l2CacheHint), std::forward(mode), std::forward(isCTAOnly), std::forward(group), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorGlobalToSharedClusterOp CpAsyncBulkTensorGlobalToSharedClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value dstMem, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::Value mbar, ::mlir::ValueRange im2colOffsets, /*optional*/::mlir::Value multicastMask, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMALoadMode mode, bool isCTAOnly, /*optional*/::mlir::NVVM::CTAGroupKindAttr group, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(dstMem), std::forward(tmaDescriptor), std::forward(coordinates), std::forward(mbar), std::forward(im2colOffsets), std::forward(multicastMask), std::forward(l2CacheHint), std::forward(mode), std::forward(isCTAOnly), std::forward(group), std::forward(predicate)); } void CpAsyncBulkTensorGlobalToSharedClusterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } CpAsyncBulkTensorGlobalToSharedClusterOp CpAsyncBulkTensorGlobalToSharedClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorGlobalToSharedClusterOp CpAsyncBulkTensorGlobalToSharedClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CpAsyncBulkTensorGlobalToSharedClusterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CpAsyncBulkTensorGlobalToSharedClusterOp CpAsyncBulkTensorGlobalToSharedClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorGlobalToSharedClusterOp CpAsyncBulkTensorGlobalToSharedClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void CpAsyncBulkTensorGlobalToSharedClusterOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.mode) properties.mode = ::mlir::NVVM::TMALoadModeAttr::get(odsBuilder.getContext(), TMALoadMode::TILE); if (!properties.isCTAOnly) properties.isCTAOnly = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult CpAsyncBulkTensorGlobalToSharedClusterOp::verifyInvariantsImpl() { auto tblgen_group = getProperties().group; (void)tblgen_group; auto tblgen_isCTAOnly = getProperties().isCTAOnly; (void)tblgen_isCTAOnly; auto tblgen_mode = getProperties().mode; (void)tblgen_mode; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps18(*this, tblgen_mode, "mode"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_isCTAOnly, "isCTAOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(*this, tblgen_group, "group"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps17(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps20(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps21(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps22(*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_NVVMOps11(*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_NVVMOps4(*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_NVVMOps23(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkTensorGlobalToSharedClusterOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult CpAsyncBulkTensorGlobalToSharedClusterOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand dstMemRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> dstMemOperands(&dstMemRawOperand, 1); ::llvm::SMLoc dstMemOperandsLoc; (void)dstMemOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand tmaDescriptorRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tmaDescriptorOperands(&tmaDescriptorRawOperand, 1); ::llvm::SMLoc tmaDescriptorOperandsLoc; (void)tmaDescriptorOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand mbarRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> mbarOperands(&mbarRawOperand, 1); ::llvm::SMLoc mbarOperandsLoc; (void)mbarOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> coordinatesOperands; ::llvm::SMLoc coordinatesOperandsLoc; (void)coordinatesOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> im2colOffsetsOperands; ::llvm::SMLoc im2colOffsetsOperandsLoc; (void)im2colOffsetsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> multicastMaskOperands; ::llvm::SMLoc multicastMaskOperandsLoc; (void)multicastMaskOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> l2CacheHintOperands; ::llvm::SMLoc l2CacheHintOperandsLoc; (void)l2CacheHintOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> predicateOperands; ::llvm::SMLoc predicateOperandsLoc; (void)predicateOperandsLoc; ::mlir::Type dstMemRawType{}; ::llvm::ArrayRef<::mlir::Type> dstMemTypes(&dstMemRawType, 1); ::mlir::Type tmaDescriptorRawType{}; ::llvm::ArrayRef<::mlir::Type> tmaDescriptorTypes(&tmaDescriptorRawType, 1); dstMemOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(dstMemRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); tmaDescriptorOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(tmaDescriptorRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); mbarOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(mbarRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); if (parser.parseKeyword("box")) return ::mlir::failure(); if (parser.parseLSquare()) return ::mlir::failure(); coordinatesOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(coordinatesOperands)) return ::mlir::failure(); if (parser.parseRSquare()) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("im2col"))) { if (parser.parseLSquare()) return ::mlir::failure(); im2colOffsetsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(im2colOffsetsOperands)) return ::mlir::failure(); if (parser.parseRSquare()) return ::mlir::failure(); } if (::mlir::succeeded(parser.parseOptionalKeyword("multicast_mask"))) { if (parser.parseEqual()) return ::mlir::failure(); { multicastMaskOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); multicastMaskOperands.push_back(operand); } } } if (::mlir::succeeded(parser.parseOptionalKeyword("l2_cache_hint"))) { if (parser.parseEqual()) return ::mlir::failure(); { l2CacheHintOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); l2CacheHintOperands.push_back(operand); } } } if (::mlir::succeeded(parser.parseOptionalKeyword("predicate"))) { if (parser.parseEqual()) return ::mlir::failure(); { predicateOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); predicateOperands.push_back(operand); } } } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dstMemRawType = type; } if (parser.parseComma()) return ::mlir::failure(); { ::mlir::LLVM::LLVMPointerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); tmaDescriptorRawType = type; } ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(coordinatesOperands.size()), 1, static_cast(im2colOffsetsOperands.size()), static_cast(multicastMaskOperands.size()), static_cast(l2CacheHintOperands.size()), static_cast(predicateOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); ::mlir::Type odsBuildableType1 = parser.getBuilder().getType<::mlir::LLVM::LLVMPointerType>(3); ::mlir::Type odsBuildableType2 = parser.getBuilder().getIntegerType(16); ::mlir::Type odsBuildableType3 = parser.getBuilder().getIntegerType(64); ::mlir::Type odsBuildableType4 = parser.getBuilder().getIntegerType(1); if (parser.resolveOperands(dstMemOperands, dstMemTypes, dstMemOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(tmaDescriptorOperands, tmaDescriptorTypes, tmaDescriptorOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(coordinatesOperands, odsBuildableType0, coordinatesOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(mbarOperands, odsBuildableType1, mbarOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(im2colOffsetsOperands, odsBuildableType2, im2colOffsetsOperandsLoc, result.operands)) return ::mlir::failure(); if (!multicastMaskOperands.empty()) { if (parser.resolveOperands(multicastMaskOperands, odsBuildableType2, multicastMaskOperandsLoc, result.operands)) return ::mlir::failure(); } if (!l2CacheHintOperands.empty()) { if (parser.resolveOperands(l2CacheHintOperands, odsBuildableType3, l2CacheHintOperandsLoc, result.operands)) return ::mlir::failure(); } if (!predicateOperands.empty()) { if (parser.resolveOperands(predicateOperands, odsBuildableType4, predicateOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void CpAsyncBulkTensorGlobalToSharedClusterOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getDstMem(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getTmaDescriptor(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMbar(); _odsPrinter << ","; _odsPrinter << ' ' << "box"; _odsPrinter << "["; _odsPrinter << getCoordinates(); _odsPrinter << "]"; if (!getIm2colOffsets().empty()) { _odsPrinter << ' ' << "im2col"; _odsPrinter << "["; _odsPrinter << getIm2colOffsets(); _odsPrinter << "]"; } if (getMulticastMask()) { _odsPrinter << ' ' << "multicast_mask"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getMulticastMask()) _odsPrinter << value; } if (getL2CacheHint()) { _odsPrinter << ' ' << "l2_cache_hint"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getL2CacheHint()) _odsPrinter << value; } if (getPredicate()) { _odsPrinter << ' ' << "predicate"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getPredicate()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModeAttr(); if(attr && (attr == ::mlir::NVVM::TMALoadModeAttr::get(odsBuilder.getContext(), TMALoadMode::TILE))) elidedAttrs.push_back("mode"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getIsCTAOnlyAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("isCTAOnly"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getDstMem().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; { auto type = getTmaDescriptor().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::LLVM::LLVMPointerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } std::string CpAsyncBulkTensorGlobalToSharedClusterOp::getPtx() { int im2colDim = getIm2colOffsets().size(); int dim = getCoordinates().size(); std::string ptx = "cp.async.bulk.tensor."; ptx += std::to_string(dim) + "d."; ptx += "shared::cluster.global.mbarrier::complete_tx::bytes"; if(im2colDim) ptx += ".im2col"; if(getMulticastMask()) ptx += ".multicast::cluster"; if(getL2CacheHint()) ptx += ".L2::cache_hint"; auto preg = [](int r) { return "%" + std::to_string(r); }; // Build Registers ptx += " [%0], [%1, {"; int r = 2; for(int i = 0; i < dim; i++) ptx += preg(r+i) + ","; ptx.pop_back(); r += dim; ptx += "} ], [%" + std::to_string(r++) + "]"; if(im2colDim) { ptx += ",{"; for(int i = 0; i < im2colDim; i++) ptx += preg(r+i) + ","; ptx.pop_back(); r += im2colDim; ptx += "}"; } if(getMulticastMask()) ptx += ", " + preg(r++); if(getL2CacheHint()) ptx += ", " + preg(r++); ptx += ";"; return ptx; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::CpAsyncBulkTensorGlobalToSharedClusterOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::CpAsyncBulkTensorGlobalToSharedClusterOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::CpAsyncBulkTensorPrefetchOp definitions //===----------------------------------------------------------------------===// namespace detail { CpAsyncBulkTensorPrefetchOpGenericAdaptorBase::CpAsyncBulkTensorPrefetchOpGenericAdaptorBase(CpAsyncBulkTensorPrefetchOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair CpAsyncBulkTensorPrefetchOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::NVVM::TMALoadModeAttr CpAsyncBulkTensorPrefetchOpGenericAdaptorBase::getModeAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::TMALoadModeAttr>(getProperties().mode); return attr; } ::mlir::NVVM::TMALoadMode CpAsyncBulkTensorPrefetchOpGenericAdaptorBase::getMode() { auto attr = getModeAttr(); return attr.getValue(); } } // namespace detail CpAsyncBulkTensorPrefetchOpAdaptor::CpAsyncBulkTensorPrefetchOpAdaptor(CpAsyncBulkTensorPrefetchOp op) : CpAsyncBulkTensorPrefetchOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CpAsyncBulkTensorPrefetchOpAdaptor::verify(::mlir::Location loc) { auto tblgen_mode = getProperties().mode; (void)tblgen_mode; if (tblgen_mode && !((::llvm::isa<::mlir::NVVM::TMALoadModeAttr>(tblgen_mode)))) return emitError(loc, "'nvvm.cp.async.bulk.tensor.prefetch' op attribute 'mode' failed to satisfy constraint: List of Load-Modes supported for TMA Tensor Ops"); return ::mlir::success(); } std::pair CpAsyncBulkTensorPrefetchOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange CpAsyncBulkTensorPrefetchOp::getCoordinatesMutable() { 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 CpAsyncBulkTensorPrefetchOp::getIm2colOffsetsMutable() { 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 CpAsyncBulkTensorPrefetchOp::getL2CacheHintMutable() { 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 CpAsyncBulkTensorPrefetchOp::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.mode; auto attr = dict.get("mode"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `mode` 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 CpAsyncBulkTensorPrefetchOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.mode; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("mode", 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 CpAsyncBulkTensorPrefetchOp::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.mode.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional CpAsyncBulkTensorPrefetchOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "mode") return prop.mode; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void CpAsyncBulkTensorPrefetchOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "mode") { prop.mode = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void CpAsyncBulkTensorPrefetchOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.mode) attrs.append("mode", prop.mode); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult CpAsyncBulkTensorPrefetchOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getModeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps18(attr, "mode", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkTensorPrefetchOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.mode))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void CpAsyncBulkTensorPrefetchOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.mode); 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)); ; } } ::mlir::NVVM::TMALoadMode CpAsyncBulkTensorPrefetchOp::getMode() { auto attr = getModeAttr(); return attr.getValue(); } void CpAsyncBulkTensorPrefetchOp::setMode(::mlir::NVVM::TMALoadMode attrValue) { getProperties().mode = ::mlir::NVVM::TMALoadModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CpAsyncBulkTensorPrefetchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::ValueRange im2colOffsets, ::mlir::NVVM::TMALoadModeAttr mode, /*optional*/::mlir::Value l2CacheHint) { odsState.addOperands(tmaDescriptor); odsState.addOperands(coordinates); odsState.addOperands(im2colOffsets); if (l2CacheHint) odsState.addOperands(l2CacheHint); ::llvm::copy(::llvm::ArrayRef({1, static_cast(coordinates.size()), static_cast(im2colOffsets.size()), (l2CacheHint ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (mode) { odsState.getOrAddProperties().mode = mode; } } CpAsyncBulkTensorPrefetchOp CpAsyncBulkTensorPrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::ValueRange im2colOffsets, ::mlir::NVVM::TMALoadModeAttr mode, /*optional*/::mlir::Value l2CacheHint) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(tmaDescriptor), std::forward(coordinates), std::forward(im2colOffsets), std::forward(mode), std::forward(l2CacheHint)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorPrefetchOp CpAsyncBulkTensorPrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::ValueRange im2colOffsets, ::mlir::NVVM::TMALoadModeAttr mode, /*optional*/::mlir::Value l2CacheHint) { return create(builder, builder.getLoc(), std::forward(tmaDescriptor), std::forward(coordinates), std::forward(im2colOffsets), std::forward(mode), std::forward(l2CacheHint)); } void CpAsyncBulkTensorPrefetchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::ValueRange im2colOffsets, ::mlir::NVVM::TMALoadModeAttr mode, /*optional*/::mlir::Value l2CacheHint) { odsState.addOperands(tmaDescriptor); odsState.addOperands(coordinates); odsState.addOperands(im2colOffsets); if (l2CacheHint) odsState.addOperands(l2CacheHint); ::llvm::copy(::llvm::ArrayRef({1, static_cast(coordinates.size()), static_cast(im2colOffsets.size()), (l2CacheHint ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (mode) { odsState.getOrAddProperties().mode = mode; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncBulkTensorPrefetchOp CpAsyncBulkTensorPrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::ValueRange im2colOffsets, ::mlir::NVVM::TMALoadModeAttr mode, /*optional*/::mlir::Value l2CacheHint) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(tmaDescriptor), std::forward(coordinates), std::forward(im2colOffsets), std::forward(mode), std::forward(l2CacheHint)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorPrefetchOp CpAsyncBulkTensorPrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::ValueRange im2colOffsets, ::mlir::NVVM::TMALoadModeAttr mode, /*optional*/::mlir::Value l2CacheHint) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(tmaDescriptor), std::forward(coordinates), std::forward(im2colOffsets), std::forward(mode), std::forward(l2CacheHint)); } void CpAsyncBulkTensorPrefetchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::ValueRange im2colOffsets, ::mlir::NVVM::TMALoadMode mode, /*optional*/::mlir::Value l2CacheHint) { odsState.addOperands(tmaDescriptor); odsState.addOperands(coordinates); odsState.addOperands(im2colOffsets); if (l2CacheHint) odsState.addOperands(l2CacheHint); ::llvm::copy(::llvm::ArrayRef({1, static_cast(coordinates.size()), static_cast(im2colOffsets.size()), (l2CacheHint ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().mode = ::mlir::NVVM::TMALoadModeAttr::get(odsBuilder.getContext(), mode); } CpAsyncBulkTensorPrefetchOp CpAsyncBulkTensorPrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::ValueRange im2colOffsets, ::mlir::NVVM::TMALoadMode mode, /*optional*/::mlir::Value l2CacheHint) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(tmaDescriptor), std::forward(coordinates), std::forward(im2colOffsets), std::forward(mode), std::forward(l2CacheHint)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorPrefetchOp CpAsyncBulkTensorPrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::ValueRange im2colOffsets, ::mlir::NVVM::TMALoadMode mode, /*optional*/::mlir::Value l2CacheHint) { return create(builder, builder.getLoc(), std::forward(tmaDescriptor), std::forward(coordinates), std::forward(im2colOffsets), std::forward(mode), std::forward(l2CacheHint)); } void CpAsyncBulkTensorPrefetchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::ValueRange im2colOffsets, ::mlir::NVVM::TMALoadMode mode, /*optional*/::mlir::Value l2CacheHint) { odsState.addOperands(tmaDescriptor); odsState.addOperands(coordinates); odsState.addOperands(im2colOffsets); if (l2CacheHint) odsState.addOperands(l2CacheHint); ::llvm::copy(::llvm::ArrayRef({1, static_cast(coordinates.size()), static_cast(im2colOffsets.size()), (l2CacheHint ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().mode = ::mlir::NVVM::TMALoadModeAttr::get(odsBuilder.getContext(), mode); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncBulkTensorPrefetchOp CpAsyncBulkTensorPrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::ValueRange im2colOffsets, ::mlir::NVVM::TMALoadMode mode, /*optional*/::mlir::Value l2CacheHint) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(tmaDescriptor), std::forward(coordinates), std::forward(im2colOffsets), std::forward(mode), std::forward(l2CacheHint)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorPrefetchOp CpAsyncBulkTensorPrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::ValueRange coordinates, ::mlir::ValueRange im2colOffsets, ::mlir::NVVM::TMALoadMode mode, /*optional*/::mlir::Value l2CacheHint) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(tmaDescriptor), std::forward(coordinates), std::forward(im2colOffsets), std::forward(mode), std::forward(l2CacheHint)); } void CpAsyncBulkTensorPrefetchOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } CpAsyncBulkTensorPrefetchOp CpAsyncBulkTensorPrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorPrefetchOp CpAsyncBulkTensorPrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CpAsyncBulkTensorPrefetchOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CpAsyncBulkTensorPrefetchOp CpAsyncBulkTensorPrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorPrefetchOp CpAsyncBulkTensorPrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void CpAsyncBulkTensorPrefetchOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.mode) properties.mode = ::mlir::NVVM::TMALoadModeAttr::get(odsBuilder.getContext(), TMALoadMode::TILE); } ::llvm::LogicalResult CpAsyncBulkTensorPrefetchOp::verifyInvariantsImpl() { auto tblgen_mode = getProperties().mode; (void)tblgen_mode; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps18(*this, tblgen_mode, "mode"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps20(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps21(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps22(*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_NVVMOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkTensorPrefetchOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult CpAsyncBulkTensorPrefetchOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand tmaDescriptorRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tmaDescriptorOperands(&tmaDescriptorRawOperand, 1); ::llvm::SMLoc tmaDescriptorOperandsLoc; (void)tmaDescriptorOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> coordinatesOperands; ::llvm::SMLoc coordinatesOperandsLoc; (void)coordinatesOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> im2colOffsetsOperands; ::llvm::SMLoc im2colOffsetsOperandsLoc; (void)im2colOffsetsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> l2CacheHintOperands; ::llvm::SMLoc l2CacheHintOperandsLoc; (void)l2CacheHintOperandsLoc; ::mlir::Type tmaDescriptorRawType{}; ::llvm::ArrayRef<::mlir::Type> tmaDescriptorTypes(&tmaDescriptorRawType, 1); tmaDescriptorOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(tmaDescriptorRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); if (parser.parseKeyword("box")) return ::mlir::failure(); if (parser.parseLSquare()) return ::mlir::failure(); coordinatesOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(coordinatesOperands)) return ::mlir::failure(); if (parser.parseRSquare()) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("im2col"))) { if (parser.parseLSquare()) return ::mlir::failure(); im2colOffsetsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(im2colOffsetsOperands)) return ::mlir::failure(); if (parser.parseRSquare()) return ::mlir::failure(); } if (::mlir::succeeded(parser.parseOptionalKeyword("l2_cache_hint"))) { if (parser.parseEqual()) return ::mlir::failure(); { l2CacheHintOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); l2CacheHintOperands.push_back(operand); } } } { 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::LLVM::LLVMPointerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); tmaDescriptorRawType = type; } ::llvm::copy(::llvm::ArrayRef({1, static_cast(coordinatesOperands.size()), static_cast(im2colOffsetsOperands.size()), static_cast(l2CacheHintOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(16); ::mlir::Type odsBuildableType2 = parser.getBuilder().getIntegerType(64); if (parser.resolveOperands(tmaDescriptorOperands, tmaDescriptorTypes, tmaDescriptorOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(coordinatesOperands, odsBuildableType0, coordinatesOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(im2colOffsetsOperands, odsBuildableType1, im2colOffsetsOperandsLoc, result.operands)) return ::mlir::failure(); if (!l2CacheHintOperands.empty()) { if (parser.resolveOperands(l2CacheHintOperands, odsBuildableType2, l2CacheHintOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void CpAsyncBulkTensorPrefetchOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getTmaDescriptor(); _odsPrinter << ","; _odsPrinter << ' ' << "box"; _odsPrinter << "["; _odsPrinter << getCoordinates(); _odsPrinter << "]"; if (!getIm2colOffsets().empty()) { _odsPrinter << ' ' << "im2col"; _odsPrinter << "["; _odsPrinter << getIm2colOffsets(); _odsPrinter << "]"; } if (getL2CacheHint()) { _odsPrinter << ' ' << "l2_cache_hint"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getL2CacheHint()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModeAttr(); if(attr && (attr == ::mlir::NVVM::TMALoadModeAttr::get(odsBuilder.getContext(), TMALoadMode::TILE))) elidedAttrs.push_back("mode"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getTmaDescriptor().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::LLVM::LLVMPointerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::CpAsyncBulkTensorPrefetchOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::CpAsyncBulkTensorPrefetchOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::CpAsyncBulkTensorReduceOp definitions //===----------------------------------------------------------------------===// namespace detail { CpAsyncBulkTensorReduceOpGenericAdaptorBase::CpAsyncBulkTensorReduceOpGenericAdaptorBase(CpAsyncBulkTensorReduceOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair CpAsyncBulkTensorReduceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::NVVM::TMAReduxKind CpAsyncBulkTensorReduceOpGenericAdaptorBase::getRedKind() { auto attr = getRedKindAttr(); return attr.getValue(); } ::mlir::NVVM::TMAStoreModeAttr CpAsyncBulkTensorReduceOpGenericAdaptorBase::getModeAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::TMAStoreModeAttr>(getProperties().mode); return attr; } ::mlir::NVVM::TMAStoreMode CpAsyncBulkTensorReduceOpGenericAdaptorBase::getMode() { auto attr = getModeAttr(); return attr.getValue(); } } // namespace detail CpAsyncBulkTensorReduceOpAdaptor::CpAsyncBulkTensorReduceOpAdaptor(CpAsyncBulkTensorReduceOp op) : CpAsyncBulkTensorReduceOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CpAsyncBulkTensorReduceOpAdaptor::verify(::mlir::Location loc) { auto tblgen_mode = getProperties().mode; (void)tblgen_mode; auto tblgen_redKind = getProperties().redKind; (void)tblgen_redKind; if (!tblgen_redKind) return emitError(loc, "'nvvm.cp.async.bulk.tensor.reduce' op requires attribute 'redKind'"); if (tblgen_redKind && !((::llvm::isa<::mlir::NVVM::TMAReduxKindAttr>(tblgen_redKind)))) return emitError(loc, "'nvvm.cp.async.bulk.tensor.reduce' op attribute 'redKind' failed to satisfy constraint: NVVM TMA redux kind"); if (tblgen_mode && !((::llvm::isa<::mlir::NVVM::TMAStoreModeAttr>(tblgen_mode)))) return emitError(loc, "'nvvm.cp.async.bulk.tensor.reduce' op attribute 'mode' failed to satisfy constraint: NVVM TMA Store Mode"); return ::mlir::success(); } std::pair CpAsyncBulkTensorReduceOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange CpAsyncBulkTensorReduceOp::getCoordinatesMutable() { 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 CpAsyncBulkTensorReduceOp::getL2CacheHintMutable() { 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 CpAsyncBulkTensorReduceOp::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.mode; auto attr = dict.get("mode"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `mode` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.redKind; auto attr = dict.get("redKind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `redKind` 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 CpAsyncBulkTensorReduceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.mode; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("mode", propStorage)); } { const auto &propStorage = prop.redKind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("redKind", 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 CpAsyncBulkTensorReduceOp::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.mode.getAsOpaquePointer()), llvm::hash_value(prop.redKind.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional CpAsyncBulkTensorReduceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "mode") return prop.mode; if (name == "redKind") return prop.redKind; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void CpAsyncBulkTensorReduceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "mode") { prop.mode = ::llvm::dyn_cast_or_null>(value); return; } if (name == "redKind") { prop.redKind = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void CpAsyncBulkTensorReduceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.mode) attrs.append("mode", prop.mode); if (prop.redKind) attrs.append("redKind", prop.redKind); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult CpAsyncBulkTensorReduceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getModeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps21(attr, "mode", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRedKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps20(attr, "redKind", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkTensorReduceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.mode))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readAttribute(prop.redKind))) 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 CpAsyncBulkTensorReduceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.mode); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeAttribute(prop.redKind); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::NVVM::TMAReduxKind CpAsyncBulkTensorReduceOp::getRedKind() { auto attr = getRedKindAttr(); return attr.getValue(); } ::mlir::NVVM::TMAStoreMode CpAsyncBulkTensorReduceOp::getMode() { auto attr = getModeAttr(); return attr.getValue(); } void CpAsyncBulkTensorReduceOp::setRedKind(::mlir::NVVM::TMAReduxKind attrValue) { getProperties().redKind = ::mlir::NVVM::TMAReduxKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CpAsyncBulkTensorReduceOp::setMode(::mlir::NVVM::TMAStoreMode attrValue) { getProperties().mode = ::mlir::NVVM::TMAStoreModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CpAsyncBulkTensorReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::NVVM::TMAReduxKindAttr redKind, ::mlir::NVVM::TMAStoreModeAttr mode, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint) { odsState.addOperands(tmaDescriptor); odsState.addOperands(srcMem); odsState.addOperands(coordinates); if (l2CacheHint) odsState.addOperands(l2CacheHint); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(coordinates.size()), (l2CacheHint ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().redKind = redKind; if (mode) { odsState.getOrAddProperties().mode = mode; } } CpAsyncBulkTensorReduceOp CpAsyncBulkTensorReduceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::NVVM::TMAReduxKindAttr redKind, ::mlir::NVVM::TMAStoreModeAttr mode, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(tmaDescriptor), std::forward(srcMem), std::forward(redKind), std::forward(mode), std::forward(coordinates), std::forward(l2CacheHint)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorReduceOp CpAsyncBulkTensorReduceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::NVVM::TMAReduxKindAttr redKind, ::mlir::NVVM::TMAStoreModeAttr mode, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint) { return create(builder, builder.getLoc(), std::forward(tmaDescriptor), std::forward(srcMem), std::forward(redKind), std::forward(mode), std::forward(coordinates), std::forward(l2CacheHint)); } void CpAsyncBulkTensorReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::NVVM::TMAReduxKindAttr redKind, ::mlir::NVVM::TMAStoreModeAttr mode, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint) { odsState.addOperands(tmaDescriptor); odsState.addOperands(srcMem); odsState.addOperands(coordinates); if (l2CacheHint) odsState.addOperands(l2CacheHint); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(coordinates.size()), (l2CacheHint ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().redKind = redKind; if (mode) { odsState.getOrAddProperties().mode = mode; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncBulkTensorReduceOp CpAsyncBulkTensorReduceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::NVVM::TMAReduxKindAttr redKind, ::mlir::NVVM::TMAStoreModeAttr mode, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(tmaDescriptor), std::forward(srcMem), std::forward(redKind), std::forward(mode), std::forward(coordinates), std::forward(l2CacheHint)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorReduceOp CpAsyncBulkTensorReduceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::NVVM::TMAReduxKindAttr redKind, ::mlir::NVVM::TMAStoreModeAttr mode, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(tmaDescriptor), std::forward(srcMem), std::forward(redKind), std::forward(mode), std::forward(coordinates), std::forward(l2CacheHint)); } void CpAsyncBulkTensorReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::NVVM::TMAReduxKind redKind, ::mlir::NVVM::TMAStoreMode mode, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint) { odsState.addOperands(tmaDescriptor); odsState.addOperands(srcMem); odsState.addOperands(coordinates); if (l2CacheHint) odsState.addOperands(l2CacheHint); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(coordinates.size()), (l2CacheHint ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().redKind = ::mlir::NVVM::TMAReduxKindAttr::get(odsBuilder.getContext(), redKind); odsState.getOrAddProperties().mode = ::mlir::NVVM::TMAStoreModeAttr::get(odsBuilder.getContext(), mode); } CpAsyncBulkTensorReduceOp CpAsyncBulkTensorReduceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::NVVM::TMAReduxKind redKind, ::mlir::NVVM::TMAStoreMode mode, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(tmaDescriptor), std::forward(srcMem), std::forward(redKind), std::forward(mode), std::forward(coordinates), std::forward(l2CacheHint)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorReduceOp CpAsyncBulkTensorReduceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::NVVM::TMAReduxKind redKind, ::mlir::NVVM::TMAStoreMode mode, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint) { return create(builder, builder.getLoc(), std::forward(tmaDescriptor), std::forward(srcMem), std::forward(redKind), std::forward(mode), std::forward(coordinates), std::forward(l2CacheHint)); } void CpAsyncBulkTensorReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::NVVM::TMAReduxKind redKind, ::mlir::NVVM::TMAStoreMode mode, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint) { odsState.addOperands(tmaDescriptor); odsState.addOperands(srcMem); odsState.addOperands(coordinates); if (l2CacheHint) odsState.addOperands(l2CacheHint); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(coordinates.size()), (l2CacheHint ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().redKind = ::mlir::NVVM::TMAReduxKindAttr::get(odsBuilder.getContext(), redKind); odsState.getOrAddProperties().mode = ::mlir::NVVM::TMAStoreModeAttr::get(odsBuilder.getContext(), mode); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncBulkTensorReduceOp CpAsyncBulkTensorReduceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::NVVM::TMAReduxKind redKind, ::mlir::NVVM::TMAStoreMode mode, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(tmaDescriptor), std::forward(srcMem), std::forward(redKind), std::forward(mode), std::forward(coordinates), std::forward(l2CacheHint)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorReduceOp CpAsyncBulkTensorReduceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::NVVM::TMAReduxKind redKind, ::mlir::NVVM::TMAStoreMode mode, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(tmaDescriptor), std::forward(srcMem), std::forward(redKind), std::forward(mode), std::forward(coordinates), std::forward(l2CacheHint)); } void CpAsyncBulkTensorReduceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } CpAsyncBulkTensorReduceOp CpAsyncBulkTensorReduceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorReduceOp CpAsyncBulkTensorReduceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CpAsyncBulkTensorReduceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CpAsyncBulkTensorReduceOp CpAsyncBulkTensorReduceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorReduceOp CpAsyncBulkTensorReduceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void CpAsyncBulkTensorReduceOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.mode) properties.mode = ::mlir::NVVM::TMAStoreModeAttr::get(odsBuilder.getContext(), TMAStoreMode::TILE); } ::llvm::LogicalResult CpAsyncBulkTensorReduceOp::verifyInvariantsImpl() { auto tblgen_mode = getProperties().mode; (void)tblgen_mode; auto tblgen_redKind = getProperties().redKind; (void)tblgen_redKind; if (!tblgen_redKind) return emitOpError("requires attribute 'redKind'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps20(*this, tblgen_redKind, "redKind"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps21(*this, tblgen_mode, "mode"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps24(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps21(*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_NVVMOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkTensorReduceOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult CpAsyncBulkTensorReduceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand tmaDescriptorRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tmaDescriptorOperands(&tmaDescriptorRawOperand, 1); ::llvm::SMLoc tmaDescriptorOperandsLoc; (void)tmaDescriptorOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand srcMemRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcMemOperands(&srcMemRawOperand, 1); ::llvm::SMLoc srcMemOperandsLoc; (void)srcMemOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> coordinatesOperands; ::llvm::SMLoc coordinatesOperandsLoc; (void)coordinatesOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> l2CacheHintOperands; ::llvm::SMLoc l2CacheHintOperandsLoc; (void)l2CacheHintOperandsLoc; ::mlir::Type tmaDescriptorRawType{}; ::llvm::ArrayRef<::mlir::Type> tmaDescriptorTypes(&tmaDescriptorRawType, 1); ::mlir::Type srcMemRawType{}; ::llvm::ArrayRef<::mlir::Type> srcMemTypes(&srcMemRawType, 1); tmaDescriptorOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(tmaDescriptorRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); srcMemOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcMemRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); if (parser.parseKeyword("box")) return ::mlir::failure(); if (parser.parseLSquare()) return ::mlir::failure(); coordinatesOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(coordinatesOperands)) return ::mlir::failure(); if (parser.parseRSquare()) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("l2_cache_hint"))) { if (parser.parseEqual()) return ::mlir::failure(); { l2CacheHintOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); l2CacheHintOperands.push_back(operand); } } } { 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::LLVM::LLVMPointerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); tmaDescriptorRawType = type; } if (parser.parseComma()) return ::mlir::failure(); { ::mlir::LLVM::LLVMPointerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcMemRawType = type; } ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(coordinatesOperands.size()), static_cast(l2CacheHintOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(64); if (parser.resolveOperands(tmaDescriptorOperands, tmaDescriptorTypes, tmaDescriptorOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(srcMemOperands, srcMemTypes, srcMemOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(coordinatesOperands, odsBuildableType0, coordinatesOperandsLoc, result.operands)) return ::mlir::failure(); if (!l2CacheHintOperands.empty()) { if (parser.resolveOperands(l2CacheHintOperands, odsBuildableType1, l2CacheHintOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void CpAsyncBulkTensorReduceOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getTmaDescriptor(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSrcMem(); _odsPrinter << ","; _odsPrinter << ' ' << "box"; _odsPrinter << "["; _odsPrinter << getCoordinates(); _odsPrinter << "]"; if (getL2CacheHint()) { _odsPrinter << ' ' << "l2_cache_hint"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getL2CacheHint()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModeAttr(); if(attr && (attr == ::mlir::NVVM::TMAStoreModeAttr::get(odsBuilder.getContext(), TMAStoreMode::TILE))) elidedAttrs.push_back("mode"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getTmaDescriptor().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::LLVM::LLVMPointerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; { auto type = getSrcMem().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::LLVM::LLVMPointerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::CpAsyncBulkTensorReduceOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::CpAsyncBulkTensorReduceOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::CpAsyncBulkTensorSharedCTAToGlobalOp definitions //===----------------------------------------------------------------------===// namespace detail { CpAsyncBulkTensorSharedCTAToGlobalOpGenericAdaptorBase::CpAsyncBulkTensorSharedCTAToGlobalOpGenericAdaptorBase(CpAsyncBulkTensorSharedCTAToGlobalOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair CpAsyncBulkTensorSharedCTAToGlobalOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::NVVM::TMAStoreModeAttr CpAsyncBulkTensorSharedCTAToGlobalOpGenericAdaptorBase::getModeAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::TMAStoreModeAttr>(getProperties().mode); return attr; } ::mlir::NVVM::TMAStoreMode CpAsyncBulkTensorSharedCTAToGlobalOpGenericAdaptorBase::getMode() { auto attr = getModeAttr(); return attr.getValue(); } } // namespace detail CpAsyncBulkTensorSharedCTAToGlobalOpAdaptor::CpAsyncBulkTensorSharedCTAToGlobalOpAdaptor(CpAsyncBulkTensorSharedCTAToGlobalOp op) : CpAsyncBulkTensorSharedCTAToGlobalOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CpAsyncBulkTensorSharedCTAToGlobalOpAdaptor::verify(::mlir::Location loc) { auto tblgen_mode = getProperties().mode; (void)tblgen_mode; if (tblgen_mode && !((::llvm::isa<::mlir::NVVM::TMAStoreModeAttr>(tblgen_mode)))) return emitError(loc, "'nvvm.cp.async.bulk.tensor.global.shared.cta' op attribute 'mode' failed to satisfy constraint: NVVM TMA Store Mode"); return ::mlir::success(); } std::pair CpAsyncBulkTensorSharedCTAToGlobalOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange CpAsyncBulkTensorSharedCTAToGlobalOp::getCoordinatesMutable() { 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 CpAsyncBulkTensorSharedCTAToGlobalOp::getL2CacheHintMutable() { 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 CpAsyncBulkTensorSharedCTAToGlobalOp::getPredicateMutable() { 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 CpAsyncBulkTensorSharedCTAToGlobalOp::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.mode; auto attr = dict.get("mode"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `mode` 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 CpAsyncBulkTensorSharedCTAToGlobalOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.mode; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("mode", 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 CpAsyncBulkTensorSharedCTAToGlobalOp::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.mode.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional CpAsyncBulkTensorSharedCTAToGlobalOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "mode") return prop.mode; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void CpAsyncBulkTensorSharedCTAToGlobalOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "mode") { prop.mode = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void CpAsyncBulkTensorSharedCTAToGlobalOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.mode) attrs.append("mode", prop.mode); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult CpAsyncBulkTensorSharedCTAToGlobalOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getModeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps21(attr, "mode", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkTensorSharedCTAToGlobalOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.mode))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void CpAsyncBulkTensorSharedCTAToGlobalOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.mode); 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)); ; } } ::mlir::NVVM::TMAStoreMode CpAsyncBulkTensorSharedCTAToGlobalOp::getMode() { auto attr = getModeAttr(); return attr.getValue(); } void CpAsyncBulkTensorSharedCTAToGlobalOp::setMode(::mlir::NVVM::TMAStoreMode attrValue) { getProperties().mode = ::mlir::NVVM::TMAStoreModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CpAsyncBulkTensorSharedCTAToGlobalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMAStoreModeAttr mode, /*optional*/::mlir::Value predicate) { odsState.addOperands(tmaDescriptor); odsState.addOperands(srcMem); odsState.addOperands(coordinates); if (l2CacheHint) odsState.addOperands(l2CacheHint); if (predicate) odsState.addOperands(predicate); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(coordinates.size()), (l2CacheHint ? 1 : 0), (predicate ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (mode) { odsState.getOrAddProperties().mode = mode; } } CpAsyncBulkTensorSharedCTAToGlobalOp CpAsyncBulkTensorSharedCTAToGlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMAStoreModeAttr mode, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(tmaDescriptor), std::forward(srcMem), std::forward(coordinates), std::forward(l2CacheHint), std::forward(mode), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorSharedCTAToGlobalOp CpAsyncBulkTensorSharedCTAToGlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMAStoreModeAttr mode, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(tmaDescriptor), std::forward(srcMem), std::forward(coordinates), std::forward(l2CacheHint), std::forward(mode), std::forward(predicate)); } void CpAsyncBulkTensorSharedCTAToGlobalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMAStoreModeAttr mode, /*optional*/::mlir::Value predicate) { odsState.addOperands(tmaDescriptor); odsState.addOperands(srcMem); odsState.addOperands(coordinates); if (l2CacheHint) odsState.addOperands(l2CacheHint); if (predicate) odsState.addOperands(predicate); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(coordinates.size()), (l2CacheHint ? 1 : 0), (predicate ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (mode) { odsState.getOrAddProperties().mode = mode; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncBulkTensorSharedCTAToGlobalOp CpAsyncBulkTensorSharedCTAToGlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMAStoreModeAttr mode, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(tmaDescriptor), std::forward(srcMem), std::forward(coordinates), std::forward(l2CacheHint), std::forward(mode), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorSharedCTAToGlobalOp CpAsyncBulkTensorSharedCTAToGlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMAStoreModeAttr mode, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(tmaDescriptor), std::forward(srcMem), std::forward(coordinates), std::forward(l2CacheHint), std::forward(mode), std::forward(predicate)); } void CpAsyncBulkTensorSharedCTAToGlobalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMAStoreMode mode, /*optional*/::mlir::Value predicate) { odsState.addOperands(tmaDescriptor); odsState.addOperands(srcMem); odsState.addOperands(coordinates); if (l2CacheHint) odsState.addOperands(l2CacheHint); if (predicate) odsState.addOperands(predicate); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(coordinates.size()), (l2CacheHint ? 1 : 0), (predicate ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().mode = ::mlir::NVVM::TMAStoreModeAttr::get(odsBuilder.getContext(), mode); } CpAsyncBulkTensorSharedCTAToGlobalOp CpAsyncBulkTensorSharedCTAToGlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMAStoreMode mode, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(tmaDescriptor), std::forward(srcMem), std::forward(coordinates), std::forward(l2CacheHint), std::forward(mode), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorSharedCTAToGlobalOp CpAsyncBulkTensorSharedCTAToGlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMAStoreMode mode, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(tmaDescriptor), std::forward(srcMem), std::forward(coordinates), std::forward(l2CacheHint), std::forward(mode), std::forward(predicate)); } void CpAsyncBulkTensorSharedCTAToGlobalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMAStoreMode mode, /*optional*/::mlir::Value predicate) { odsState.addOperands(tmaDescriptor); odsState.addOperands(srcMem); odsState.addOperands(coordinates); if (l2CacheHint) odsState.addOperands(l2CacheHint); if (predicate) odsState.addOperands(predicate); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(coordinates.size()), (l2CacheHint ? 1 : 0), (predicate ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().mode = ::mlir::NVVM::TMAStoreModeAttr::get(odsBuilder.getContext(), mode); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncBulkTensorSharedCTAToGlobalOp CpAsyncBulkTensorSharedCTAToGlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMAStoreMode mode, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(tmaDescriptor), std::forward(srcMem), std::forward(coordinates), std::forward(l2CacheHint), std::forward(mode), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorSharedCTAToGlobalOp CpAsyncBulkTensorSharedCTAToGlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value tmaDescriptor, ::mlir::Value srcMem, ::mlir::ValueRange coordinates, /*optional*/::mlir::Value l2CacheHint, ::mlir::NVVM::TMAStoreMode mode, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(tmaDescriptor), std::forward(srcMem), std::forward(coordinates), std::forward(l2CacheHint), std::forward(mode), std::forward(predicate)); } void CpAsyncBulkTensorSharedCTAToGlobalOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } CpAsyncBulkTensorSharedCTAToGlobalOp CpAsyncBulkTensorSharedCTAToGlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorSharedCTAToGlobalOp CpAsyncBulkTensorSharedCTAToGlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CpAsyncBulkTensorSharedCTAToGlobalOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CpAsyncBulkTensorSharedCTAToGlobalOp CpAsyncBulkTensorSharedCTAToGlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkTensorSharedCTAToGlobalOp CpAsyncBulkTensorSharedCTAToGlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void CpAsyncBulkTensorSharedCTAToGlobalOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.mode) properties.mode = ::mlir::NVVM::TMAStoreModeAttr::get(odsBuilder.getContext(), TMAStoreMode::TILE); } ::llvm::LogicalResult CpAsyncBulkTensorSharedCTAToGlobalOp::verifyInvariantsImpl() { auto tblgen_mode = getProperties().mode; (void)tblgen_mode; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps21(*this, tblgen_mode, "mode"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps20(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps21(*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_NVVMOps4(*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_NVVMOps23(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkTensorSharedCTAToGlobalOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult CpAsyncBulkTensorSharedCTAToGlobalOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand tmaDescriptorRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tmaDescriptorOperands(&tmaDescriptorRawOperand, 1); ::llvm::SMLoc tmaDescriptorOperandsLoc; (void)tmaDescriptorOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand srcMemRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcMemOperands(&srcMemRawOperand, 1); ::llvm::SMLoc srcMemOperandsLoc; (void)srcMemOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> coordinatesOperands; ::llvm::SMLoc coordinatesOperandsLoc; (void)coordinatesOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> l2CacheHintOperands; ::llvm::SMLoc l2CacheHintOperandsLoc; (void)l2CacheHintOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> predicateOperands; ::llvm::SMLoc predicateOperandsLoc; (void)predicateOperandsLoc; ::mlir::Type tmaDescriptorRawType{}; ::llvm::ArrayRef<::mlir::Type> tmaDescriptorTypes(&tmaDescriptorRawType, 1); ::mlir::Type srcMemRawType{}; ::llvm::ArrayRef<::mlir::Type> srcMemTypes(&srcMemRawType, 1); tmaDescriptorOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(tmaDescriptorRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); srcMemOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcMemRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); if (parser.parseKeyword("box")) return ::mlir::failure(); if (parser.parseLSquare()) return ::mlir::failure(); coordinatesOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(coordinatesOperands)) return ::mlir::failure(); if (parser.parseRSquare()) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("l2_cache_hint"))) { if (parser.parseEqual()) return ::mlir::failure(); { l2CacheHintOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); l2CacheHintOperands.push_back(operand); } } } if (::mlir::succeeded(parser.parseOptionalComma())) { if (parser.parseKeyword("predicate")) return ::mlir::failure(); if (parser.parseEqual()) return ::mlir::failure(); { predicateOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); predicateOperands.push_back(operand); } } } { 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::LLVM::LLVMPointerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); tmaDescriptorRawType = type; } if (parser.parseComma()) return ::mlir::failure(); { ::mlir::LLVM::LLVMPointerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcMemRawType = type; } ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(coordinatesOperands.size()), static_cast(l2CacheHintOperands.size()), static_cast(predicateOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(64); ::mlir::Type odsBuildableType2 = parser.getBuilder().getIntegerType(1); if (parser.resolveOperands(tmaDescriptorOperands, tmaDescriptorTypes, tmaDescriptorOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(srcMemOperands, srcMemTypes, srcMemOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(coordinatesOperands, odsBuildableType0, coordinatesOperandsLoc, result.operands)) return ::mlir::failure(); if (!l2CacheHintOperands.empty()) { if (parser.resolveOperands(l2CacheHintOperands, odsBuildableType1, l2CacheHintOperandsLoc, result.operands)) return ::mlir::failure(); } if (!predicateOperands.empty()) { if (parser.resolveOperands(predicateOperands, odsBuildableType2, predicateOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void CpAsyncBulkTensorSharedCTAToGlobalOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getTmaDescriptor(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSrcMem(); _odsPrinter << ","; _odsPrinter << ' ' << "box"; _odsPrinter << "["; _odsPrinter << getCoordinates(); _odsPrinter << "]"; if (getL2CacheHint()) { _odsPrinter << ' ' << "l2_cache_hint"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getL2CacheHint()) _odsPrinter << value; } if (getPredicate()) { _odsPrinter << ","; _odsPrinter << ' ' << "predicate"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getPredicate()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModeAttr(); if(attr && (attr == ::mlir::NVVM::TMAStoreModeAttr::get(odsBuilder.getContext(), TMAStoreMode::TILE))) elidedAttrs.push_back("mode"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getTmaDescriptor().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::LLVM::LLVMPointerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; { auto type = getSrcMem().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::LLVM::LLVMPointerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } std::string CpAsyncBulkTensorSharedCTAToGlobalOp::getPtx() { int dim = getCoordinates().size(); std::string ptx = "cp.async.bulk.tensor."; ptx += std::to_string(dim) + "d."; ptx += "global.shared::cta.bulk_group"; if(dim == 1) ptx += " [%0, {%2} ], [%1];"; if(dim == 2) ptx += " [%0, {%2, %3} ], [%1];"; if(dim == 3) ptx += " [%0, {%2, %3, %4} ], [%1];"; if(dim == 4) ptx += " [%0, {%2, %3, %4, %5} ], [%1];"; if(dim == 5) ptx += " [%0, {%2, %3, %4, %5, %6} ], [%1];"; return ptx; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::CpAsyncBulkTensorSharedCTAToGlobalOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::CpAsyncBulkTensorSharedCTAToGlobalOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::CpAsyncBulkWaitGroupOp definitions //===----------------------------------------------------------------------===// namespace detail { CpAsyncBulkWaitGroupOpGenericAdaptorBase::CpAsyncBulkWaitGroupOpGenericAdaptorBase(CpAsyncBulkWaitGroupOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} uint32_t CpAsyncBulkWaitGroupOpGenericAdaptorBase::getGroup() { auto attr = getGroupAttr(); return attr.getValue().getZExtValue(); } ::std::optional CpAsyncBulkWaitGroupOpGenericAdaptorBase::getRead() { auto attr = getReadAttr(); return attr ? ::std::optional(attr != nullptr) : (::std::nullopt); } } // namespace detail CpAsyncBulkWaitGroupOpAdaptor::CpAsyncBulkWaitGroupOpAdaptor(CpAsyncBulkWaitGroupOp op) : CpAsyncBulkWaitGroupOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CpAsyncBulkWaitGroupOpAdaptor::verify(::mlir::Location loc) { auto tblgen_group = getProperties().group; (void)tblgen_group; if (!tblgen_group) return emitError(loc, "'nvvm.cp.async.bulk.wait_group' op requires attribute 'group'"); auto tblgen_read = getProperties().read; (void)tblgen_read; if (tblgen_group && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_group))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_group).getType().isSignlessInteger(32)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_group).getInt() >= 0)))) return emitError(loc, "'nvvm.cp.async.bulk.wait_group' op attribute 'group' failed to satisfy constraint: 32-bit signless integer attribute whose minimum value is 0"); if (tblgen_read && !((::llvm::isa<::mlir::UnitAttr>(tblgen_read)))) return emitError(loc, "'nvvm.cp.async.bulk.wait_group' op attribute 'read' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkWaitGroupOp::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.group; auto attr = dict.get("group"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `group` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.read; auto attr = dict.get("read"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `read` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute CpAsyncBulkWaitGroupOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.group; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("group", propStorage)); } { const auto &propStorage = prop.read; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("read", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code CpAsyncBulkWaitGroupOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.group.getAsOpaquePointer()), llvm::hash_value(prop.read.getAsOpaquePointer())); } std::optional CpAsyncBulkWaitGroupOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "group") return prop.group; if (name == "read") return prop.read; return std::nullopt; } void CpAsyncBulkWaitGroupOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "group") { prop.group = ::llvm::dyn_cast_or_null>(value); return; } if (name == "read") { prop.read = ::llvm::dyn_cast_or_null>(value); return; } } void CpAsyncBulkWaitGroupOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.group) attrs.append("group", prop.group); if (prop.read) attrs.append("read", prop.read); } ::llvm::LogicalResult CpAsyncBulkWaitGroupOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getGroupAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps22(attr, "group", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReadAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "read", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkWaitGroupOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.group))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.read))) return ::mlir::failure(); return ::mlir::success(); } void CpAsyncBulkWaitGroupOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.group); writer.writeOptionalAttribute(prop.read); } uint32_t CpAsyncBulkWaitGroupOp::getGroup() { auto attr = getGroupAttr(); return attr.getValue().getZExtValue(); } ::std::optional CpAsyncBulkWaitGroupOp::getRead() { auto attr = getReadAttr(); return attr ? ::std::optional(attr != nullptr) : (::std::nullopt); } void CpAsyncBulkWaitGroupOp::setGroup(uint32_t attrValue) { getProperties().group = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); } void CpAsyncBulkWaitGroupOp::setRead(bool attrValue) { auto &odsProp = getProperties().read; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void CpAsyncBulkWaitGroupOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::IntegerAttr group, /*optional*/::mlir::UnitAttr read) { odsState.getOrAddProperties().group = group; if (read) { odsState.getOrAddProperties().read = read; } } CpAsyncBulkWaitGroupOp CpAsyncBulkWaitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::IntegerAttr group, /*optional*/::mlir::UnitAttr read) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(group), std::forward(read)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkWaitGroupOp CpAsyncBulkWaitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::IntegerAttr group, /*optional*/::mlir::UnitAttr read) { return create(builder, builder.getLoc(), std::forward(group), std::forward(read)); } void CpAsyncBulkWaitGroupOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr group, /*optional*/::mlir::UnitAttr read) { odsState.getOrAddProperties().group = group; if (read) { odsState.getOrAddProperties().read = read; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncBulkWaitGroupOp CpAsyncBulkWaitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr group, /*optional*/::mlir::UnitAttr read) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(group), std::forward(read)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkWaitGroupOp CpAsyncBulkWaitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr group, /*optional*/::mlir::UnitAttr read) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(group), std::forward(read)); } void CpAsyncBulkWaitGroupOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, uint32_t group, /*optional*/::mlir::UnitAttr read) { odsState.getOrAddProperties().group = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), group); if (read) { odsState.getOrAddProperties().read = read; } } CpAsyncBulkWaitGroupOp CpAsyncBulkWaitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, uint32_t group, /*optional*/::mlir::UnitAttr read) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(group), std::forward(read)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkWaitGroupOp CpAsyncBulkWaitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, uint32_t group, /*optional*/::mlir::UnitAttr read) { return create(builder, builder.getLoc(), std::forward(group), std::forward(read)); } void CpAsyncBulkWaitGroupOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, uint32_t group, /*optional*/::mlir::UnitAttr read) { odsState.getOrAddProperties().group = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), group); if (read) { odsState.getOrAddProperties().read = read; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncBulkWaitGroupOp CpAsyncBulkWaitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, uint32_t group, /*optional*/::mlir::UnitAttr read) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(group), std::forward(read)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkWaitGroupOp CpAsyncBulkWaitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, uint32_t group, /*optional*/::mlir::UnitAttr read) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(group), std::forward(read)); } void CpAsyncBulkWaitGroupOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } CpAsyncBulkWaitGroupOp CpAsyncBulkWaitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkWaitGroupOp CpAsyncBulkWaitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CpAsyncBulkWaitGroupOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CpAsyncBulkWaitGroupOp CpAsyncBulkWaitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncBulkWaitGroupOp CpAsyncBulkWaitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult CpAsyncBulkWaitGroupOp::verifyInvariantsImpl() { auto tblgen_group = getProperties().group; (void)tblgen_group; if (!tblgen_group) return emitOpError("requires attribute 'group'"); auto tblgen_read = getProperties().read; (void)tblgen_read; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps22(*this, tblgen_group, "group"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_read, "read"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult CpAsyncBulkWaitGroupOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult CpAsyncBulkWaitGroupOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::IntegerAttr groupAttr; if (parser.parseCustomAttributeWithFallback(groupAttr, parser.getBuilder().getIntegerType(32))) { return ::mlir::failure(); } if (groupAttr) result.getOrAddProperties().group = groupAttr; { 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 CpAsyncBulkWaitGroupOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getGroupAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("group"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::CpAsyncBulkWaitGroupOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::CpAsyncBulkWaitGroupOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::CpAsyncCommitGroupOp definitions //===----------------------------------------------------------------------===// namespace detail { CpAsyncCommitGroupOpGenericAdaptorBase::CpAsyncCommitGroupOpGenericAdaptorBase(CpAsyncCommitGroupOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail CpAsyncCommitGroupOpAdaptor::CpAsyncCommitGroupOpAdaptor(CpAsyncCommitGroupOp op) : CpAsyncCommitGroupOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CpAsyncCommitGroupOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult CpAsyncCommitGroupOp::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 CpAsyncCommitGroupOp::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 CpAsyncCommitGroupOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional CpAsyncCommitGroupOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void CpAsyncCommitGroupOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void CpAsyncCommitGroupOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult CpAsyncCommitGroupOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void CpAsyncCommitGroupOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { } CpAsyncCommitGroupOp CpAsyncCommitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncCommitGroupOp CpAsyncCommitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void CpAsyncCommitGroupOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncCommitGroupOp CpAsyncCommitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncCommitGroupOp CpAsyncCommitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void CpAsyncCommitGroupOp::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); } CpAsyncCommitGroupOp CpAsyncCommitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncCommitGroupOp CpAsyncCommitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CpAsyncCommitGroupOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CpAsyncCommitGroupOp CpAsyncCommitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncCommitGroupOp CpAsyncCommitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult CpAsyncCommitGroupOp::verifyInvariantsImpl() { return ::mlir::success(); } ::llvm::LogicalResult CpAsyncCommitGroupOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult CpAsyncCommitGroupOp::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 CpAsyncCommitGroupOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::CpAsyncCommitGroupOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::CpAsyncMBarrierArriveOp definitions //===----------------------------------------------------------------------===// namespace detail { CpAsyncMBarrierArriveOpGenericAdaptorBase::CpAsyncMBarrierArriveOpGenericAdaptorBase(CpAsyncMBarrierArriveOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::IntegerAttr CpAsyncMBarrierArriveOpGenericAdaptorBase::getNoincAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().noinc); return attr; } bool CpAsyncMBarrierArriveOpGenericAdaptorBase::getNoinc() { auto attr = getNoincAttr(); return attr.getValue().getZExtValue(); } } // namespace detail CpAsyncMBarrierArriveOpAdaptor::CpAsyncMBarrierArriveOpAdaptor(CpAsyncMBarrierArriveOp op) : CpAsyncMBarrierArriveOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CpAsyncMBarrierArriveOpAdaptor::verify(::mlir::Location loc) { auto tblgen_noinc = getProperties().noinc; (void)tblgen_noinc; if (tblgen_noinc && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_noinc))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_noinc).getType().isSignlessInteger(1))))) return emitError(loc, "'nvvm.cp.async.mbarrier.arrive' op attribute 'noinc' failed to satisfy constraint: 1-bit signless integer attribute"); return ::mlir::success(); } ::llvm::LogicalResult CpAsyncMBarrierArriveOp::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.noinc; auto attr = dict.get("noinc"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `noinc` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute CpAsyncMBarrierArriveOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.noinc; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("noinc", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code CpAsyncMBarrierArriveOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.noinc.getAsOpaquePointer())); } std::optional CpAsyncMBarrierArriveOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "noinc") return prop.noinc; return std::nullopt; } void CpAsyncMBarrierArriveOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "noinc") { prop.noinc = ::llvm::dyn_cast_or_null>(value); return; } } void CpAsyncMBarrierArriveOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.noinc) attrs.append("noinc", prop.noinc); } ::llvm::LogicalResult CpAsyncMBarrierArriveOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getNoincAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps23(attr, "noinc", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncMBarrierArriveOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.noinc))) return ::mlir::failure(); return ::mlir::success(); } void CpAsyncMBarrierArriveOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.noinc); } bool CpAsyncMBarrierArriveOp::getNoinc() { auto attr = getNoincAttr(); return attr.getValue().getZExtValue(); } void CpAsyncMBarrierArriveOp::setNoinc(bool attrValue) { getProperties().noinc = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(1), attrValue); } void CpAsyncMBarrierArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::IntegerAttr noinc) { odsState.addOperands(addr); if (noinc) { odsState.getOrAddProperties().noinc = noinc; } } CpAsyncMBarrierArriveOp CpAsyncMBarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::IntegerAttr noinc) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(noinc)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncMBarrierArriveOp CpAsyncMBarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::IntegerAttr noinc) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(noinc)); } void CpAsyncMBarrierArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::IntegerAttr noinc) { odsState.addOperands(addr); if (noinc) { odsState.getOrAddProperties().noinc = noinc; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncMBarrierArriveOp CpAsyncMBarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::IntegerAttr noinc) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(noinc)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncMBarrierArriveOp CpAsyncMBarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::IntegerAttr noinc) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(noinc)); } void CpAsyncMBarrierArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, bool noinc) { odsState.addOperands(addr); odsState.getOrAddProperties().noinc = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(1), noinc); } CpAsyncMBarrierArriveOp CpAsyncMBarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, bool noinc) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(noinc)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncMBarrierArriveOp CpAsyncMBarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, bool noinc) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(noinc)); } void CpAsyncMBarrierArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, bool noinc) { odsState.addOperands(addr); odsState.getOrAddProperties().noinc = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(1), noinc); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncMBarrierArriveOp CpAsyncMBarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, bool noinc) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(noinc)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncMBarrierArriveOp CpAsyncMBarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, bool noinc) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(noinc)); } void CpAsyncMBarrierArriveOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } CpAsyncMBarrierArriveOp CpAsyncMBarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncMBarrierArriveOp CpAsyncMBarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CpAsyncMBarrierArriveOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CpAsyncMBarrierArriveOp CpAsyncMBarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncMBarrierArriveOp CpAsyncMBarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void CpAsyncMBarrierArriveOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.noinc) properties.noinc = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(1), 0); } ::llvm::LogicalResult CpAsyncMBarrierArriveOp::verifyInvariantsImpl() { auto tblgen_noinc = getProperties().noinc; (void)tblgen_noinc; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps23(*this, tblgen_noinc, "noinc"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps3(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncMBarrierArriveOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult CpAsyncMBarrierArriveOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand addrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> addrOperands(&addrRawOperand, 1); ::llvm::SMLoc addrOperandsLoc; (void)addrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.resolveOperands(addrOperands, allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void CpAsyncMBarrierArriveOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getNoincAttr(); if(attr && (attr == odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(1), 0))) elidedAttrs.push_back("noinc"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::CpAsyncMBarrierArriveOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::CpAsyncMBarrierArriveOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::CpAsyncOp definitions //===----------------------------------------------------------------------===// namespace detail { CpAsyncOpGenericAdaptorBase::CpAsyncOpGenericAdaptorBase(CpAsyncOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair CpAsyncOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } uint32_t CpAsyncOpGenericAdaptorBase::getSize() { auto attr = getSizeAttr(); return attr.getValue().getZExtValue(); } ::mlir::NVVM::LoadCacheModifierKind CpAsyncOpGenericAdaptorBase::getModifier() { auto attr = getModifierAttr(); return attr.getValue(); } } // namespace detail CpAsyncOpAdaptor::CpAsyncOpAdaptor(CpAsyncOp op) : CpAsyncOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CpAsyncOpAdaptor::verify(::mlir::Location loc) { auto tblgen_modifier = getProperties().modifier; (void)tblgen_modifier; if (!tblgen_modifier) return emitError(loc, "'nvvm.cp.async.shared.global' op requires attribute 'modifier'"); auto tblgen_size = getProperties().size; (void)tblgen_size; if (!tblgen_size) return emitError(loc, "'nvvm.cp.async.shared.global' op requires attribute 'size'"); if (tblgen_size && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_size))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_size).getType().isSignlessInteger(32))))) return emitError(loc, "'nvvm.cp.async.shared.global' op attribute 'size' failed to satisfy constraint: 32-bit signless integer attribute"); if (tblgen_modifier && !((::llvm::isa<::mlir::NVVM::LoadCacheModifierKindAttr>(tblgen_modifier)))) return emitError(loc, "'nvvm.cp.async.shared.global' op attribute 'modifier' failed to satisfy constraint: NVVM load cache modifier kind"); return ::mlir::success(); } std::pair CpAsyncOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange CpAsyncOp::getCpSizeMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult CpAsyncOp::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.modifier; auto attr = dict.get("modifier"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifier` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.size; auto attr = dict.get("size"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `size` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute CpAsyncOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.modifier; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifier", propStorage)); } { const auto &propStorage = prop.size; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("size", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code CpAsyncOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.modifier.getAsOpaquePointer()), llvm::hash_value(prop.size.getAsOpaquePointer())); } std::optional CpAsyncOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "modifier") return prop.modifier; if (name == "size") return prop.size; return std::nullopt; } void CpAsyncOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "modifier") { prop.modifier = ::llvm::dyn_cast_or_null>(value); return; } if (name == "size") { prop.size = ::llvm::dyn_cast_or_null>(value); return; } } void CpAsyncOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.modifier) attrs.append("modifier", prop.modifier); if (prop.size) attrs.append("size", prop.size); } ::llvm::LogicalResult CpAsyncOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getModifierAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps25(attr, "modifier", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSizeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(attr, "size", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.modifier))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.size))) return ::mlir::failure(); return ::mlir::success(); } void CpAsyncOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.modifier); writer.writeAttribute(prop.size); } uint32_t CpAsyncOp::getSize() { auto attr = getSizeAttr(); return attr.getValue().getZExtValue(); } ::mlir::NVVM::LoadCacheModifierKind CpAsyncOp::getModifier() { auto attr = getModifierAttr(); return attr.getValue(); } void CpAsyncOp::setSize(uint32_t attrValue) { getProperties().size = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); } void CpAsyncOp::setModifier(::mlir::NVVM::LoadCacheModifierKind attrValue) { getProperties().modifier = ::mlir::NVVM::LoadCacheModifierKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CpAsyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value dst, ::mlir::Value src, ::mlir::IntegerAttr size, ::mlir::NVVM::LoadCacheModifierKindAttr modifier, /*optional*/::mlir::Value cpSize) { odsState.addOperands(dst); odsState.addOperands(src); if (cpSize) odsState.addOperands(cpSize); odsState.getOrAddProperties().size = size; odsState.getOrAddProperties().modifier = modifier; } CpAsyncOp CpAsyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value dst, ::mlir::Value src, ::mlir::IntegerAttr size, ::mlir::NVVM::LoadCacheModifierKindAttr modifier, /*optional*/::mlir::Value cpSize) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(size), std::forward(modifier), std::forward(cpSize)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncOp CpAsyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value dst, ::mlir::Value src, ::mlir::IntegerAttr size, ::mlir::NVVM::LoadCacheModifierKindAttr modifier, /*optional*/::mlir::Value cpSize) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(size), std::forward(modifier), std::forward(cpSize)); } void CpAsyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value dst, ::mlir::Value src, ::mlir::IntegerAttr size, ::mlir::NVVM::LoadCacheModifierKindAttr modifier, /*optional*/::mlir::Value cpSize) { odsState.addOperands(dst); odsState.addOperands(src); if (cpSize) odsState.addOperands(cpSize); odsState.getOrAddProperties().size = size; odsState.getOrAddProperties().modifier = modifier; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncOp CpAsyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value dst, ::mlir::Value src, ::mlir::IntegerAttr size, ::mlir::NVVM::LoadCacheModifierKindAttr modifier, /*optional*/::mlir::Value cpSize) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(dst), std::forward(src), std::forward(size), std::forward(modifier), std::forward(cpSize)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncOp CpAsyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value dst, ::mlir::Value src, ::mlir::IntegerAttr size, ::mlir::NVVM::LoadCacheModifierKindAttr modifier, /*optional*/::mlir::Value cpSize) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(dst), std::forward(src), std::forward(size), std::forward(modifier), std::forward(cpSize)); } void CpAsyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value dst, ::mlir::Value src, uint32_t size, ::mlir::NVVM::LoadCacheModifierKind modifier, /*optional*/::mlir::Value cpSize) { odsState.addOperands(dst); odsState.addOperands(src); if (cpSize) odsState.addOperands(cpSize); odsState.getOrAddProperties().size = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), size); odsState.getOrAddProperties().modifier = ::mlir::NVVM::LoadCacheModifierKindAttr::get(odsBuilder.getContext(), modifier); } CpAsyncOp CpAsyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value dst, ::mlir::Value src, uint32_t size, ::mlir::NVVM::LoadCacheModifierKind modifier, /*optional*/::mlir::Value cpSize) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(size), std::forward(modifier), std::forward(cpSize)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncOp CpAsyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value dst, ::mlir::Value src, uint32_t size, ::mlir::NVVM::LoadCacheModifierKind modifier, /*optional*/::mlir::Value cpSize) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(size), std::forward(modifier), std::forward(cpSize)); } void CpAsyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value dst, ::mlir::Value src, uint32_t size, ::mlir::NVVM::LoadCacheModifierKind modifier, /*optional*/::mlir::Value cpSize) { odsState.addOperands(dst); odsState.addOperands(src); if (cpSize) odsState.addOperands(cpSize); odsState.getOrAddProperties().size = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), size); odsState.getOrAddProperties().modifier = ::mlir::NVVM::LoadCacheModifierKindAttr::get(odsBuilder.getContext(), modifier); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncOp CpAsyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value dst, ::mlir::Value src, uint32_t size, ::mlir::NVVM::LoadCacheModifierKind modifier, /*optional*/::mlir::Value cpSize) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(dst), std::forward(src), std::forward(size), std::forward(modifier), std::forward(cpSize)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncOp CpAsyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value dst, ::mlir::Value src, uint32_t size, ::mlir::NVVM::LoadCacheModifierKind modifier, /*optional*/::mlir::Value cpSize) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(dst), std::forward(src), std::forward(size), std::forward(modifier), std::forward(cpSize)); } void CpAsyncOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } CpAsyncOp CpAsyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncOp CpAsyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CpAsyncOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CpAsyncOp CpAsyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncOp CpAsyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult CpAsyncOp::verifyInvariantsImpl() { auto tblgen_modifier = getProperties().modifier; (void)tblgen_modifier; if (!tblgen_modifier) return emitOpError("requires attribute 'modifier'"); auto tblgen_size = getProperties().size; (void)tblgen_size; if (!tblgen_size) return emitOpError("requires attribute 'size'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(*this, tblgen_size, "size"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps25(*this, tblgen_modifier, "modifier"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps18(*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_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult CpAsyncOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand dstRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> dstOperands(&dstRawOperand, 1); ::llvm::SMLoc dstOperandsLoc; (void)dstOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::IntegerAttr sizeAttr; ::mlir::NVVM::LoadCacheModifierKindAttr modifierAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> cpSizeOperands; ::llvm::SMLoc cpSizeOperandsLoc; (void)cpSizeOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; dstOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(dstRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(sizeAttr, parser.getBuilder().getIntegerType(32))) { return ::mlir::failure(); } if (sizeAttr) result.getOrAddProperties().size = sizeAttr; if (parser.parseComma()) return ::mlir::failure(); if (parser.parseKeyword("cache")) return ::mlir::failure(); if (parser.parseEqual()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(modifierAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (modifierAttr) result.getOrAddProperties().modifier = modifierAttr; if (::mlir::succeeded(parser.parseOptionalComma())) { { cpSizeOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); cpSizeOperands.push_back(operand); } } } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.resolveOperands(::llvm::concat(dstOperands, srcOperands, cpSizeOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void CpAsyncOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getDst(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSrc(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getSizeAttr()); _odsPrinter << ","; _odsPrinter << ' ' << "cache"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getModifierAttr()); if (getCpSize()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getCpSize()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("size"); elidedAttrs.push_back("modifier"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::CpAsyncOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::CpAsyncOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::CpAsyncWaitGroupOp definitions //===----------------------------------------------------------------------===// namespace detail { CpAsyncWaitGroupOpGenericAdaptorBase::CpAsyncWaitGroupOpGenericAdaptorBase(CpAsyncWaitGroupOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} uint32_t CpAsyncWaitGroupOpGenericAdaptorBase::getN() { auto attr = getNAttr(); return attr.getValue().getZExtValue(); } } // namespace detail CpAsyncWaitGroupOpAdaptor::CpAsyncWaitGroupOpAdaptor(CpAsyncWaitGroupOp op) : CpAsyncWaitGroupOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CpAsyncWaitGroupOpAdaptor::verify(::mlir::Location loc) { auto tblgen_n = getProperties().n; (void)tblgen_n; if (!tblgen_n) return emitError(loc, "'nvvm.cp.async.wait.group' op requires attribute 'n'"); if (tblgen_n && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_n))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_n).getType().isSignlessInteger(32))))) return emitError(loc, "'nvvm.cp.async.wait.group' op attribute 'n' failed to satisfy constraint: 32-bit signless integer attribute"); return ::mlir::success(); } ::llvm::LogicalResult CpAsyncWaitGroupOp::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.n; auto attr = dict.get("n"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `n` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute CpAsyncWaitGroupOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.n; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("n", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code CpAsyncWaitGroupOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.n.getAsOpaquePointer())); } std::optional CpAsyncWaitGroupOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "n") return prop.n; return std::nullopt; } void CpAsyncWaitGroupOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "n") { prop.n = ::llvm::dyn_cast_or_null>(value); return; } } void CpAsyncWaitGroupOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.n) attrs.append("n", prop.n); } ::llvm::LogicalResult CpAsyncWaitGroupOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getNAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(attr, "n", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult CpAsyncWaitGroupOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.n))) return ::mlir::failure(); return ::mlir::success(); } void CpAsyncWaitGroupOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.n); } uint32_t CpAsyncWaitGroupOp::getN() { auto attr = getNAttr(); return attr.getValue().getZExtValue(); } void CpAsyncWaitGroupOp::setN(uint32_t attrValue) { getProperties().n = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); } void CpAsyncWaitGroupOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::IntegerAttr n) { odsState.getOrAddProperties().n = n; } CpAsyncWaitGroupOp CpAsyncWaitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::IntegerAttr n) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(n)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncWaitGroupOp CpAsyncWaitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::IntegerAttr n) { return create(builder, builder.getLoc(), std::forward(n)); } void CpAsyncWaitGroupOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr n) { odsState.getOrAddProperties().n = n; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncWaitGroupOp CpAsyncWaitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr n) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(n)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncWaitGroupOp CpAsyncWaitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr n) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(n)); } void CpAsyncWaitGroupOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, uint32_t n) { odsState.getOrAddProperties().n = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), n); } CpAsyncWaitGroupOp CpAsyncWaitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, uint32_t n) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(n)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncWaitGroupOp CpAsyncWaitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, uint32_t n) { return create(builder, builder.getLoc(), std::forward(n)); } void CpAsyncWaitGroupOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, uint32_t n) { odsState.getOrAddProperties().n = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), n); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CpAsyncWaitGroupOp CpAsyncWaitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, uint32_t n) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(n)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncWaitGroupOp CpAsyncWaitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, uint32_t n) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(n)); } void CpAsyncWaitGroupOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } CpAsyncWaitGroupOp CpAsyncWaitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncWaitGroupOp CpAsyncWaitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CpAsyncWaitGroupOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CpAsyncWaitGroupOp CpAsyncWaitGroupOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CpAsyncWaitGroupOp CpAsyncWaitGroupOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult CpAsyncWaitGroupOp::verifyInvariantsImpl() { auto tblgen_n = getProperties().n; (void)tblgen_n; if (!tblgen_n) return emitOpError("requires attribute 'n'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(*this, tblgen_n, "n"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult CpAsyncWaitGroupOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult CpAsyncWaitGroupOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::IntegerAttr nAttr; if (parser.parseCustomAttributeWithFallback(nAttr, parser.getBuilder().getIntegerType(32))) { return ::mlir::failure(); } if (nAttr) result.getOrAddProperties().n = nAttr; { 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 CpAsyncWaitGroupOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getNAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("n"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::CpAsyncWaitGroupOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::CpAsyncWaitGroupOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::DivFOp definitions //===----------------------------------------------------------------------===// namespace detail { DivFOpGenericAdaptorBase::DivFOpGenericAdaptorBase(DivFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::FPRoundingModeAttr DivFOpGenericAdaptorBase::getRndAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::FPRoundingModeAttr>(getProperties().rnd); return attr; } ::mlir::NVVM::FPRoundingMode DivFOpGenericAdaptorBase::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::BoolAttr DivFOpGenericAdaptorBase::getFtzAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().ftz); return attr; } bool DivFOpGenericAdaptorBase::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } ::mlir::BoolAttr DivFOpGenericAdaptorBase::getApproxAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().approx); return attr; } bool DivFOpGenericAdaptorBase::getApprox() { auto attr = getApproxAttr(); return attr.getValue(); } ::mlir::BoolAttr DivFOpGenericAdaptorBase::getFullAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().full); return attr; } bool DivFOpGenericAdaptorBase::getFull() { auto attr = getFullAttr(); return attr.getValue(); } } // namespace detail DivFOpAdaptor::DivFOpAdaptor(DivFOp op) : DivFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DivFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_approx = getProperties().approx; (void)tblgen_approx; auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; auto tblgen_full = getProperties().full; (void)tblgen_full; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; if (tblgen_rnd && !(((::llvm::isa<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd))) && (((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::NONE)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RM)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RN)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RP)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RZ))))) return emitError(loc, "'nvvm.divf' op attribute 'rnd' failed to satisfy constraint: NVVM FPRoundingMode kind whose value is one of {none, rm, rn, rp, rz}"); if (tblgen_ftz && !((::llvm::isa<::mlir::BoolAttr>(tblgen_ftz)))) return emitError(loc, "'nvvm.divf' op attribute 'ftz' failed to satisfy constraint: bool attribute"); if (tblgen_approx && !((::llvm::isa<::mlir::BoolAttr>(tblgen_approx)))) return emitError(loc, "'nvvm.divf' op attribute 'approx' failed to satisfy constraint: bool attribute"); if (tblgen_full && !((::llvm::isa<::mlir::BoolAttr>(tblgen_full)))) return emitError(loc, "'nvvm.divf' op attribute 'full' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult DivFOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.approx; auto attr = dict.get("approx"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `approx` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.ftz; auto attr = dict.get("ftz"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ftz` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.full; auto attr = dict.get("full"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `full` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.rnd; auto attr = dict.get("rnd"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `rnd` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute DivFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.approx; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("approx", propStorage)); } { const auto &propStorage = prop.ftz; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ftz", propStorage)); } { const auto &propStorage = prop.full; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("full", propStorage)); } { const auto &propStorage = prop.rnd; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("rnd", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DivFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.approx.getAsOpaquePointer()), llvm::hash_value(prop.ftz.getAsOpaquePointer()), llvm::hash_value(prop.full.getAsOpaquePointer()), llvm::hash_value(prop.rnd.getAsOpaquePointer())); } std::optional DivFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "approx") return prop.approx; if (name == "ftz") return prop.ftz; if (name == "full") return prop.full; if (name == "rnd") return prop.rnd; return std::nullopt; } void DivFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "approx") { prop.approx = ::llvm::dyn_cast_or_null>(value); return; } if (name == "ftz") { prop.ftz = ::llvm::dyn_cast_or_null>(value); return; } if (name == "full") { prop.full = ::llvm::dyn_cast_or_null>(value); return; } if (name == "rnd") { prop.rnd = ::llvm::dyn_cast_or_null>(value); return; } } void DivFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.approx) attrs.append("approx", prop.approx); if (prop.ftz) attrs.append("ftz", prop.ftz); if (prop.full) attrs.append("full", prop.full); if (prop.rnd) attrs.append("rnd", prop.rnd); } ::llvm::LogicalResult DivFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getApproxAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "approx", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getFtzAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "ftz", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getFullAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "full", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRndAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps1(attr, "rnd", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult DivFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.approx))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.ftz))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.full))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.rnd))) return ::mlir::failure(); return ::mlir::success(); } void DivFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.approx); writer.writeOptionalAttribute(prop.ftz); writer.writeOptionalAttribute(prop.full); writer.writeOptionalAttribute(prop.rnd); } ::mlir::NVVM::FPRoundingMode DivFOp::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } bool DivFOp::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } bool DivFOp::getApprox() { auto attr = getApproxAttr(); return attr.getValue(); } bool DivFOp::getFull() { auto attr = getFullAttr(); return attr.getValue(); } void DivFOp::setRnd(::mlir::NVVM::FPRoundingMode attrValue) { getProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void DivFOp::setFtz(bool attrValue) { getProperties().ftz = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void DivFOp::setApprox(bool attrValue) { getProperties().approx = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void DivFOp::setFull(bool attrValue) { getProperties().full = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz, ::mlir::BoolAttr approx, ::mlir::BoolAttr full) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (ftz) { odsState.getOrAddProperties().ftz = ftz; } if (approx) { odsState.getOrAddProperties().approx = approx; } if (full) { odsState.getOrAddProperties().full = full; } odsState.addTypes(res); } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz, ::mlir::BoolAttr approx, ::mlir::BoolAttr full) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(ftz), std::forward(approx), std::forward(full)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz, ::mlir::BoolAttr approx, ::mlir::BoolAttr full) { return create(builder, builder.getLoc(), std::forward(res), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(ftz), std::forward(approx), std::forward(full)); } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz, ::mlir::BoolAttr approx, ::mlir::BoolAttr full) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (ftz) { odsState.getOrAddProperties().ftz = ftz; } if (approx) { odsState.getOrAddProperties().approx = approx; } if (full) { odsState.getOrAddProperties().full = full; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DivFOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz, ::mlir::BoolAttr approx, ::mlir::BoolAttr full) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(ftz), std::forward(approx), std::forward(full)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz, ::mlir::BoolAttr approx, ::mlir::BoolAttr full) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(ftz), std::forward(approx), std::forward(full)); } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz, ::mlir::BoolAttr approx, ::mlir::BoolAttr full) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (ftz) { odsState.getOrAddProperties().ftz = ftz; } if (approx) { odsState.getOrAddProperties().approx = approx; } if (full) { odsState.getOrAddProperties().full = full; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz, ::mlir::BoolAttr approx, ::mlir::BoolAttr full) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(ftz), std::forward(approx), std::forward(full)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz, ::mlir::BoolAttr approx, ::mlir::BoolAttr full) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(ftz), std::forward(approx), std::forward(full)); } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, bool ftz, bool approx, bool full) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); odsState.getOrAddProperties().approx = odsBuilder.getBoolAttr(approx); odsState.getOrAddProperties().full = odsBuilder.getBoolAttr(full); odsState.addTypes(res); } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, bool ftz, bool approx, bool full) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(ftz), std::forward(approx), std::forward(full)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, bool ftz, bool approx, bool full) { return create(builder, builder.getLoc(), std::forward(res), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(ftz), std::forward(approx), std::forward(full)); } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, bool ftz, bool approx, bool full) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); odsState.getOrAddProperties().approx = odsBuilder.getBoolAttr(approx); odsState.getOrAddProperties().full = odsBuilder.getBoolAttr(full); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DivFOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, bool ftz, bool approx, bool full) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(ftz), std::forward(approx), std::forward(full)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, bool ftz, bool approx, bool full) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(ftz), std::forward(approx), std::forward(full)); } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, bool ftz, bool approx, bool full) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); odsState.getOrAddProperties().approx = odsBuilder.getBoolAttr(approx); odsState.getOrAddProperties().full = odsBuilder.getBoolAttr(full); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, bool ftz, bool approx, bool full) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(ftz), std::forward(approx), std::forward(full)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, bool ftz, bool approx, bool full) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(ftz), std::forward(approx), std::forward(full)); } void DivFOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DivFOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void DivFOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DivFOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void DivFOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.rnd) properties.rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), FPRoundingMode::NONE); if (!properties.ftz) properties.ftz = odsBuilder.getBoolAttr(false); if (!properties.approx) properties.approx = odsBuilder.getBoolAttr(false); if (!properties.full) properties.full = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult DivFOp::verifyInvariantsImpl() { auto tblgen_approx = getProperties().approx; (void)tblgen_approx; auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; auto tblgen_full = getProperties().full; (void)tblgen_full; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps1(*this, tblgen_rnd, "rnd"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_ftz, "ftz"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_approx, "approx"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_full, "full"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps25(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps25(*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_NVVMOps25(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DivFOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult DivFOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); if (operands.size() <= 0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[0].getType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult DivFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); if (parser.resolveOperands(lhsOperands, resTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DivFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getRndAttr(); if(attr && (attr == ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), FPRoundingMode::NONE))) elidedAttrs.push_back("rnd"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFtzAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("ftz"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getApproxAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("approx"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFullAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("full"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void DivFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::DivFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::DivFOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::DotAccumulate2WayOp definitions //===----------------------------------------------------------------------===// namespace detail { DotAccumulate2WayOpGenericAdaptorBase::DotAccumulate2WayOpGenericAdaptorBase(DotAccumulate2WayOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::DotAccumulateType DotAccumulate2WayOpGenericAdaptorBase::getAType() { auto attr = getATypeAttr(); return attr.getValue(); } ::mlir::NVVM::DotAccumulateType DotAccumulate2WayOpGenericAdaptorBase::getBType() { auto attr = getBTypeAttr(); return attr.getValue(); } bool DotAccumulate2WayOpGenericAdaptorBase::getBHi() { auto attr = getBHiAttr(); return attr.getValue(); } } // namespace detail DotAccumulate2WayOpAdaptor::DotAccumulate2WayOpAdaptor(DotAccumulate2WayOp op) : DotAccumulate2WayOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DotAccumulate2WayOpAdaptor::verify(::mlir::Location loc) { auto tblgen_a_type = getProperties().a_type; (void)tblgen_a_type; if (!tblgen_a_type) return emitError(loc, "'nvvm.dot.accumulate.2way' op requires attribute 'a_type'"); auto tblgen_b_hi = getProperties().b_hi; (void)tblgen_b_hi; if (!tblgen_b_hi) return emitError(loc, "'nvvm.dot.accumulate.2way' op requires attribute 'b_hi'"); auto tblgen_b_type = getProperties().b_type; (void)tblgen_b_type; if (!tblgen_b_type) return emitError(loc, "'nvvm.dot.accumulate.2way' op requires attribute 'b_type'"); if (tblgen_a_type && !((::llvm::isa<::mlir::NVVM::DotAccumulateTypeAttr>(tblgen_a_type)))) return emitError(loc, "'nvvm.dot.accumulate.2way' op attribute 'a_type' failed to satisfy constraint: NVVM DotAccumulateType"); if (tblgen_b_type && !((::llvm::isa<::mlir::NVVM::DotAccumulateTypeAttr>(tblgen_b_type)))) return emitError(loc, "'nvvm.dot.accumulate.2way' op attribute 'b_type' failed to satisfy constraint: NVVM DotAccumulateType"); if (tblgen_b_hi && !((::llvm::isa<::mlir::BoolAttr>(tblgen_b_hi)))) return emitError(loc, "'nvvm.dot.accumulate.2way' op attribute 'b_hi' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult DotAccumulate2WayOp::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.a_type; auto attr = dict.get("a_type"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `a_type` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.b_hi; auto attr = dict.get("b_hi"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `b_hi` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.b_type; auto attr = dict.get("b_type"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `b_type` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute DotAccumulate2WayOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.a_type; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("a_type", propStorage)); } { const auto &propStorage = prop.b_hi; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("b_hi", propStorage)); } { const auto &propStorage = prop.b_type; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("b_type", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DotAccumulate2WayOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.a_type.getAsOpaquePointer()), llvm::hash_value(prop.b_hi.getAsOpaquePointer()), llvm::hash_value(prop.b_type.getAsOpaquePointer())); } std::optional DotAccumulate2WayOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "a_type") return prop.a_type; if (name == "b_hi") return prop.b_hi; if (name == "b_type") return prop.b_type; return std::nullopt; } void DotAccumulate2WayOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "a_type") { prop.a_type = ::llvm::dyn_cast_or_null>(value); return; } if (name == "b_hi") { prop.b_hi = ::llvm::dyn_cast_or_null>(value); return; } if (name == "b_type") { prop.b_type = ::llvm::dyn_cast_or_null>(value); return; } } void DotAccumulate2WayOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.a_type) attrs.append("a_type", prop.a_type); if (prop.b_hi) attrs.append("b_hi", prop.b_hi); if (prop.b_type) attrs.append("b_type", prop.b_type); } ::llvm::LogicalResult DotAccumulate2WayOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getATypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps26(attr, "a_type", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getBHiAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "b_hi", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getBTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps26(attr, "b_type", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult DotAccumulate2WayOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.a_type))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.b_hi))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.b_type))) return ::mlir::failure(); return ::mlir::success(); } void DotAccumulate2WayOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.a_type); writer.writeAttribute(prop.b_hi); writer.writeAttribute(prop.b_type); } ::mlir::NVVM::DotAccumulateType DotAccumulate2WayOp::getAType() { auto attr = getATypeAttr(); return attr.getValue(); } ::mlir::NVVM::DotAccumulateType DotAccumulate2WayOp::getBType() { auto attr = getBTypeAttr(); return attr.getValue(); } bool DotAccumulate2WayOp::getBHi() { auto attr = getBHiAttr(); return attr.getValue(); } void DotAccumulate2WayOp::setAType(::mlir::NVVM::DotAccumulateType attrValue) { getProperties().a_type = ::mlir::NVVM::DotAccumulateTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void DotAccumulate2WayOp::setBType(::mlir::NVVM::DotAccumulateType attrValue) { getProperties().b_type = ::mlir::NVVM::DotAccumulateTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void DotAccumulate2WayOp::setBHi(bool attrValue) { getProperties().b_hi = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void DotAccumulate2WayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c, ::mlir::BoolAttr b_hi) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().a_type = a_type; odsState.getOrAddProperties().b_type = b_type; odsState.getOrAddProperties().b_hi = b_hi; odsState.addTypes(res); } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c, ::mlir::BoolAttr b_hi) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c), std::forward(b_hi)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c, ::mlir::BoolAttr b_hi) { return create(builder, builder.getLoc(), std::forward(res), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c), std::forward(b_hi)); } void DotAccumulate2WayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c, ::mlir::BoolAttr b_hi) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().a_type = a_type; odsState.getOrAddProperties().b_type = b_type; odsState.getOrAddProperties().b_hi = b_hi; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DotAccumulate2WayOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c, ::mlir::BoolAttr b_hi) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c), std::forward(b_hi)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c, ::mlir::BoolAttr b_hi) { return create(builder, builder.getLoc(), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c), std::forward(b_hi)); } void DotAccumulate2WayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c, ::mlir::BoolAttr b_hi) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().a_type = a_type; odsState.getOrAddProperties().b_type = b_type; odsState.getOrAddProperties().b_hi = b_hi; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c, ::mlir::BoolAttr b_hi) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c), std::forward(b_hi)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c, ::mlir::BoolAttr b_hi) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c), std::forward(b_hi)); } void DotAccumulate2WayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c, bool b_hi) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().a_type = ::mlir::NVVM::DotAccumulateTypeAttr::get(odsBuilder.getContext(), a_type); odsState.getOrAddProperties().b_type = ::mlir::NVVM::DotAccumulateTypeAttr::get(odsBuilder.getContext(), b_type); odsState.getOrAddProperties().b_hi = odsBuilder.getBoolAttr(b_hi); odsState.addTypes(res); } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c, bool b_hi) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c), std::forward(b_hi)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c, bool b_hi) { return create(builder, builder.getLoc(), std::forward(res), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c), std::forward(b_hi)); } void DotAccumulate2WayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c, bool b_hi) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().a_type = ::mlir::NVVM::DotAccumulateTypeAttr::get(odsBuilder.getContext(), a_type); odsState.getOrAddProperties().b_type = ::mlir::NVVM::DotAccumulateTypeAttr::get(odsBuilder.getContext(), b_type); odsState.getOrAddProperties().b_hi = odsBuilder.getBoolAttr(b_hi); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DotAccumulate2WayOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c, bool b_hi) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c), std::forward(b_hi)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c, bool b_hi) { return create(builder, builder.getLoc(), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c), std::forward(b_hi)); } void DotAccumulate2WayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c, bool b_hi) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().a_type = ::mlir::NVVM::DotAccumulateTypeAttr::get(odsBuilder.getContext(), a_type); odsState.getOrAddProperties().b_type = ::mlir::NVVM::DotAccumulateTypeAttr::get(odsBuilder.getContext(), b_type); odsState.getOrAddProperties().b_hi = odsBuilder.getBoolAttr(b_hi); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c, bool b_hi) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c), std::forward(b_hi)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c, bool b_hi) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c), std::forward(b_hi)); } void DotAccumulate2WayOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void DotAccumulate2WayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DotAccumulate2WayOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void DotAccumulate2WayOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void DotAccumulate2WayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DotAccumulate2WayOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate2WayOp DotAccumulate2WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult DotAccumulate2WayOp::verifyInvariantsImpl() { auto tblgen_a_type = getProperties().a_type; (void)tblgen_a_type; if (!tblgen_a_type) return emitOpError("requires attribute 'a_type'"); auto tblgen_b_hi = getProperties().b_hi; (void)tblgen_b_hi; if (!tblgen_b_hi) return emitOpError("requires attribute 'b_hi'"); auto tblgen_b_type = getProperties().b_type; (void)tblgen_b_type; if (!tblgen_b_type) return emitOpError("requires attribute 'b_type'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps26(*this, tblgen_a_type, "a_type"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps26(*this, tblgen_b_type, "b_type"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_b_hi, "b_hi"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps26(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps15(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DotAccumulate2WayOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult DotAccumulate2WayOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult DotAccumulate2WayOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand aRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(&aRawOperand, 1); ::llvm::SMLoc aOperandsLoc; (void)aOperandsLoc; ::mlir::NVVM::DotAccumulateTypeAttr a_typeAttr; ::mlir::OpAsmParser::UnresolvedOperand bRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> bOperands(&bRawOperand, 1); ::llvm::SMLoc bOperandsLoc; (void)bOperandsLoc; ::mlir::NVVM::DotAccumulateTypeAttr b_typeAttr; ::mlir::OpAsmParser::UnresolvedOperand cRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> cOperands(&cRawOperand, 1); ::llvm::SMLoc cOperandsLoc; (void)cOperandsLoc; ::mlir::Type aRawType{}; ::llvm::ArrayRef<::mlir::Type> aTypes(&aRawType, 1); ::mlir::Type bRawType{}; ::llvm::ArrayRef<::mlir::Type> bTypes(&bRawType, 1); aOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(aRawOperand)) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(a_typeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (a_typeAttr) result.getOrAddProperties().a_type = a_typeAttr; if (parser.parseComma()) return ::mlir::failure(); bOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(bRawOperand)) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(b_typeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (b_typeAttr) result.getOrAddProperties().b_type = b_typeAttr; if (parser.parseComma()) return ::mlir::failure(); cOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(cRawOperand)) 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); aRawType = type; } if (parser.parseComma()) return ::mlir::failure(); { ::mlir::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); bRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); result.addTypes(odsBuildableType0); if (parser.resolveOperands(aOperands, aTypes, aOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(bOperands, bTypes, bOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(cOperands, odsBuildableType0, cOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DotAccumulate2WayOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getA(); _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getATypeAttr()); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getB(); _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getBTypeAttr()); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getC(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("a_type"); elidedAttrs.push_back("b_type"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getA().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; { auto type = getB().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::DotAccumulate2WayOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::DotAccumulate2WayOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::DotAccumulate4WayOp definitions //===----------------------------------------------------------------------===// namespace detail { DotAccumulate4WayOpGenericAdaptorBase::DotAccumulate4WayOpGenericAdaptorBase(DotAccumulate4WayOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::DotAccumulateType DotAccumulate4WayOpGenericAdaptorBase::getAType() { auto attr = getATypeAttr(); return attr.getValue(); } ::mlir::NVVM::DotAccumulateType DotAccumulate4WayOpGenericAdaptorBase::getBType() { auto attr = getBTypeAttr(); return attr.getValue(); } } // namespace detail DotAccumulate4WayOpAdaptor::DotAccumulate4WayOpAdaptor(DotAccumulate4WayOp op) : DotAccumulate4WayOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DotAccumulate4WayOpAdaptor::verify(::mlir::Location loc) { auto tblgen_a_type = getProperties().a_type; (void)tblgen_a_type; if (!tblgen_a_type) return emitError(loc, "'nvvm.dot.accumulate.4way' op requires attribute 'a_type'"); auto tblgen_b_type = getProperties().b_type; (void)tblgen_b_type; if (!tblgen_b_type) return emitError(loc, "'nvvm.dot.accumulate.4way' op requires attribute 'b_type'"); if (tblgen_a_type && !((::llvm::isa<::mlir::NVVM::DotAccumulateTypeAttr>(tblgen_a_type)))) return emitError(loc, "'nvvm.dot.accumulate.4way' op attribute 'a_type' failed to satisfy constraint: NVVM DotAccumulateType"); if (tblgen_b_type && !((::llvm::isa<::mlir::NVVM::DotAccumulateTypeAttr>(tblgen_b_type)))) return emitError(loc, "'nvvm.dot.accumulate.4way' op attribute 'b_type' failed to satisfy constraint: NVVM DotAccumulateType"); return ::mlir::success(); } ::llvm::LogicalResult DotAccumulate4WayOp::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.a_type; auto attr = dict.get("a_type"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `a_type` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.b_type; auto attr = dict.get("b_type"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `b_type` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute DotAccumulate4WayOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.a_type; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("a_type", propStorage)); } { const auto &propStorage = prop.b_type; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("b_type", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DotAccumulate4WayOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.a_type.getAsOpaquePointer()), llvm::hash_value(prop.b_type.getAsOpaquePointer())); } std::optional DotAccumulate4WayOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "a_type") return prop.a_type; if (name == "b_type") return prop.b_type; return std::nullopt; } void DotAccumulate4WayOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "a_type") { prop.a_type = ::llvm::dyn_cast_or_null>(value); return; } if (name == "b_type") { prop.b_type = ::llvm::dyn_cast_or_null>(value); return; } } void DotAccumulate4WayOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.a_type) attrs.append("a_type", prop.a_type); if (prop.b_type) attrs.append("b_type", prop.b_type); } ::llvm::LogicalResult DotAccumulate4WayOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getATypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps26(attr, "a_type", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getBTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps26(attr, "b_type", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult DotAccumulate4WayOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.a_type))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.b_type))) return ::mlir::failure(); return ::mlir::success(); } void DotAccumulate4WayOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.a_type); writer.writeAttribute(prop.b_type); } ::mlir::NVVM::DotAccumulateType DotAccumulate4WayOp::getAType() { auto attr = getATypeAttr(); return attr.getValue(); } ::mlir::NVVM::DotAccumulateType DotAccumulate4WayOp::getBType() { auto attr = getBTypeAttr(); return attr.getValue(); } void DotAccumulate4WayOp::setAType(::mlir::NVVM::DotAccumulateType attrValue) { getProperties().a_type = ::mlir::NVVM::DotAccumulateTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void DotAccumulate4WayOp::setBType(::mlir::NVVM::DotAccumulateType attrValue) { getProperties().b_type = ::mlir::NVVM::DotAccumulateTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void DotAccumulate4WayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().a_type = a_type; odsState.getOrAddProperties().b_type = b_type; odsState.addTypes(res); } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c) { return create(builder, builder.getLoc(), std::forward(res), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c)); } void DotAccumulate4WayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().a_type = a_type; odsState.getOrAddProperties().b_type = b_type; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DotAccumulate4WayOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c) { return create(builder, builder.getLoc(), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c)); } void DotAccumulate4WayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().a_type = a_type; odsState.getOrAddProperties().b_type = b_type; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::NVVM::DotAccumulateTypeAttr a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateTypeAttr b_type, ::mlir::Value c) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c)); } void DotAccumulate4WayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().a_type = ::mlir::NVVM::DotAccumulateTypeAttr::get(odsBuilder.getContext(), a_type); odsState.getOrAddProperties().b_type = ::mlir::NVVM::DotAccumulateTypeAttr::get(odsBuilder.getContext(), b_type); odsState.addTypes(res); } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c) { return create(builder, builder.getLoc(), std::forward(res), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c)); } void DotAccumulate4WayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().a_type = ::mlir::NVVM::DotAccumulateTypeAttr::get(odsBuilder.getContext(), a_type); odsState.getOrAddProperties().b_type = ::mlir::NVVM::DotAccumulateTypeAttr::get(odsBuilder.getContext(), b_type); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DotAccumulate4WayOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c) { return create(builder, builder.getLoc(), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c)); } void DotAccumulate4WayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().a_type = ::mlir::NVVM::DotAccumulateTypeAttr::get(odsBuilder.getContext(), a_type); odsState.getOrAddProperties().b_type = ::mlir::NVVM::DotAccumulateTypeAttr::get(odsBuilder.getContext(), b_type); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::NVVM::DotAccumulateType a_type, ::mlir::Value b, ::mlir::NVVM::DotAccumulateType b_type, ::mlir::Value c) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(a_type), std::forward(b), std::forward(b_type), std::forward(c)); } void DotAccumulate4WayOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void DotAccumulate4WayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DotAccumulate4WayOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void DotAccumulate4WayOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void DotAccumulate4WayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DotAccumulate4WayOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DotAccumulate4WayOp DotAccumulate4WayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult DotAccumulate4WayOp::verifyInvariantsImpl() { auto tblgen_a_type = getProperties().a_type; (void)tblgen_a_type; if (!tblgen_a_type) return emitOpError("requires attribute 'a_type'"); auto tblgen_b_type = getProperties().b_type; (void)tblgen_b_type; if (!tblgen_b_type) return emitOpError("requires attribute 'b_type'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps26(*this, tblgen_a_type, "a_type"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps26(*this, tblgen_b_type, "b_type"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps15(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps15(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DotAccumulate4WayOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult DotAccumulate4WayOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult DotAccumulate4WayOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand aRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(&aRawOperand, 1); ::llvm::SMLoc aOperandsLoc; (void)aOperandsLoc; ::mlir::NVVM::DotAccumulateTypeAttr a_typeAttr; ::mlir::OpAsmParser::UnresolvedOperand bRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> bOperands(&bRawOperand, 1); ::llvm::SMLoc bOperandsLoc; (void)bOperandsLoc; ::mlir::NVVM::DotAccumulateTypeAttr b_typeAttr; ::mlir::OpAsmParser::UnresolvedOperand cRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> cOperands(&cRawOperand, 1); ::llvm::SMLoc cOperandsLoc; (void)cOperandsLoc; ::mlir::Type aRawType{}; ::llvm::ArrayRef<::mlir::Type> aTypes(&aRawType, 1); ::mlir::Type bRawType{}; ::llvm::ArrayRef<::mlir::Type> bTypes(&bRawType, 1); aOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(aRawOperand)) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(a_typeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (a_typeAttr) result.getOrAddProperties().a_type = a_typeAttr; if (parser.parseComma()) return ::mlir::failure(); bOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(bRawOperand)) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(b_typeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (b_typeAttr) result.getOrAddProperties().b_type = b_typeAttr; if (parser.parseComma()) return ::mlir::failure(); cOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(cRawOperand)) 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); aRawType = type; } if (parser.parseComma()) return ::mlir::failure(); { ::mlir::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); bRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); result.addTypes(odsBuildableType0); if (parser.resolveOperands(aOperands, aTypes, aOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(bOperands, bTypes, bOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(cOperands, odsBuildableType0, cOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DotAccumulate4WayOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getA(); _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getATypeAttr()); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getB(); _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getBTypeAttr()); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getC(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("a_type"); elidedAttrs.push_back("b_type"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getA().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; { auto type = getB().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::DotAccumulate4WayOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::DotAccumulate4WayOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::DynamicSmemSize definitions //===----------------------------------------------------------------------===// namespace detail { DynamicSmemSizeGenericAdaptorBase::DynamicSmemSizeGenericAdaptorBase(DynamicSmemSize op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail DynamicSmemSizeAdaptor::DynamicSmemSizeAdaptor(DynamicSmemSize op) : DynamicSmemSizeGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DynamicSmemSizeAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult DynamicSmemSize::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 DynamicSmemSize::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 DynamicSmemSize::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional DynamicSmemSize::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void DynamicSmemSize::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void DynamicSmemSize::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult DynamicSmemSize::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void DynamicSmemSize::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } DynamicSmemSize DynamicSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DynamicSmemSize DynamicSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void DynamicSmemSize::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DynamicSmemSize::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } DynamicSmemSize DynamicSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DynamicSmemSize DynamicSmemSize::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void DynamicSmemSize::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DynamicSmemSize DynamicSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DynamicSmemSize DynamicSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void DynamicSmemSize::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); } DynamicSmemSize DynamicSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DynamicSmemSize DynamicSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void DynamicSmemSize::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DynamicSmemSize::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } DynamicSmemSize DynamicSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DynamicSmemSize DynamicSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void DynamicSmemSize::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DynamicSmemSize DynamicSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DynamicSmemSize DynamicSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void DynamicSmemSize::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DynamicSmemSize::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } DynamicSmemSize DynamicSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DynamicSmemSize DynamicSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult DynamicSmemSize::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DynamicSmemSize::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult DynamicSmemSize::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult DynamicSmemSize::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void DynamicSmemSize::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void DynamicSmemSize::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::DynamicSmemSize) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ElectSyncOp definitions //===----------------------------------------------------------------------===// namespace detail { ElectSyncOpGenericAdaptorBase::ElectSyncOpGenericAdaptorBase(ElectSyncOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ElectSyncOpGenericAdaptorBase::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 ElectSyncOpAdaptor::ElectSyncOpAdaptor(ElectSyncOp op) : ElectSyncOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ElectSyncOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair ElectSyncOp::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 ElectSyncOp::getMembermaskMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult ElectSyncOp::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 ElectSyncOp::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 ElectSyncOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional ElectSyncOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void ElectSyncOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void ElectSyncOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult ElectSyncOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void ElectSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type pred, /*optional*/::mlir::Value membermask) { if (membermask) odsState.addOperands(membermask); odsState.addTypes(pred); } ElectSyncOp ElectSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type pred, /*optional*/::mlir::Value membermask) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(pred), std::forward(membermask)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ElectSyncOp ElectSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type pred, /*optional*/::mlir::Value membermask) { return create(builder, builder.getLoc(), std::forward(pred), std::forward(membermask)); } void ElectSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value membermask) { if (membermask) odsState.addOperands(membermask); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ElectSyncOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ElectSyncOp ElectSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value membermask) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(membermask)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ElectSyncOp ElectSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value membermask) { return create(builder, builder.getLoc(), std::forward(membermask)); } void ElectSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value membermask) { if (membermask) odsState.addOperands(membermask); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ElectSyncOp ElectSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value membermask) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(membermask)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ElectSyncOp ElectSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value membermask) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(membermask)); } void ElectSyncOp::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); } ElectSyncOp ElectSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ElectSyncOp ElectSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ElectSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ElectSyncOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ElectSyncOp ElectSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ElectSyncOp ElectSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ElectSyncOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ElectSyncOp ElectSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ElectSyncOp ElectSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ElectSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ElectSyncOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ElectSyncOp ElectSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ElectSyncOp ElectSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ElectSyncOp::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_NVVMOps2(*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_NVVMOps23(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ElectSyncOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult ElectSyncOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(1); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ElectSyncOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> membermaskOperands; ::llvm::SMLoc membermaskOperandsLoc; (void)membermaskOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; { membermaskOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); membermaskOperands.push_back(operand); } } if (!membermaskOperands.empty()) { } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseArrow()) return ::mlir::failure(); if (parser.parseTypeList(allResultTypes)) return ::mlir::failure(); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); result.addTypes(allResultTypes); if (!membermaskOperands.empty()) { if (parser.resolveOperands(membermaskOperands, odsBuildableType0, membermaskOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void ElectSyncOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getMembermask()) { _odsPrinter << ' '; if (::mlir::Value value = getMembermask()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << "->"; _odsPrinter << ' '; _odsPrinter << getOperation()->getResultTypes(); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ElectSyncOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg0Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg0OpGenericAdaptorBase::EnvReg0OpGenericAdaptorBase(EnvReg0Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg0OpAdaptor::EnvReg0OpAdaptor(EnvReg0Op op) : EnvReg0OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg0OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg0Op::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 EnvReg0Op::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 EnvReg0Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg0Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg0Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg0Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg0Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg0Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg0Op EnvReg0Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg0Op EnvReg0Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg0Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg0Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg0Op EnvReg0Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg0Op EnvReg0Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg0Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg0Op EnvReg0Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg0Op EnvReg0Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg0Op::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); } EnvReg0Op EnvReg0Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg0Op EnvReg0Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg0Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg0Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg0Op EnvReg0Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg0Op EnvReg0Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg0Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg0Op EnvReg0Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg0Op EnvReg0Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg0Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg0Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg0Op EnvReg0Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg0Op EnvReg0Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg0Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg0Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg0Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg0Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg0Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg0Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg0Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg10Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg10OpGenericAdaptorBase::EnvReg10OpGenericAdaptorBase(EnvReg10Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg10OpAdaptor::EnvReg10OpAdaptor(EnvReg10Op op) : EnvReg10OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg10OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg10Op::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 EnvReg10Op::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 EnvReg10Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg10Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg10Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg10Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg10Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg10Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg10Op EnvReg10Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg10Op EnvReg10Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg10Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg10Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg10Op EnvReg10Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg10Op EnvReg10Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg10Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg10Op EnvReg10Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg10Op EnvReg10Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg10Op::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); } EnvReg10Op EnvReg10Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg10Op EnvReg10Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg10Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg10Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg10Op EnvReg10Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg10Op EnvReg10Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg10Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg10Op EnvReg10Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg10Op EnvReg10Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg10Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg10Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg10Op EnvReg10Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg10Op EnvReg10Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg10Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg10Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg10Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg10Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg10Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg10Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg10Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg11Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg11OpGenericAdaptorBase::EnvReg11OpGenericAdaptorBase(EnvReg11Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg11OpAdaptor::EnvReg11OpAdaptor(EnvReg11Op op) : EnvReg11OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg11OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg11Op::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 EnvReg11Op::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 EnvReg11Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg11Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg11Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg11Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg11Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg11Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg11Op EnvReg11Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg11Op EnvReg11Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg11Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg11Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg11Op EnvReg11Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg11Op EnvReg11Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg11Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg11Op EnvReg11Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg11Op EnvReg11Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg11Op::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); } EnvReg11Op EnvReg11Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg11Op EnvReg11Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg11Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg11Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg11Op EnvReg11Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg11Op EnvReg11Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg11Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg11Op EnvReg11Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg11Op EnvReg11Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg11Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg11Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg11Op EnvReg11Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg11Op EnvReg11Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg11Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg11Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg11Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg11Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg11Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg11Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg11Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg12Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg12OpGenericAdaptorBase::EnvReg12OpGenericAdaptorBase(EnvReg12Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg12OpAdaptor::EnvReg12OpAdaptor(EnvReg12Op op) : EnvReg12OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg12OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg12Op::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 EnvReg12Op::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 EnvReg12Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg12Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg12Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg12Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg12Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg12Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg12Op EnvReg12Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg12Op EnvReg12Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg12Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg12Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg12Op EnvReg12Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg12Op EnvReg12Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg12Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg12Op EnvReg12Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg12Op EnvReg12Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg12Op::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); } EnvReg12Op EnvReg12Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg12Op EnvReg12Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg12Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg12Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg12Op EnvReg12Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg12Op EnvReg12Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg12Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg12Op EnvReg12Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg12Op EnvReg12Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg12Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg12Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg12Op EnvReg12Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg12Op EnvReg12Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg12Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg12Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg12Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg12Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg12Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg12Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg12Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg13Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg13OpGenericAdaptorBase::EnvReg13OpGenericAdaptorBase(EnvReg13Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg13OpAdaptor::EnvReg13OpAdaptor(EnvReg13Op op) : EnvReg13OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg13OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg13Op::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 EnvReg13Op::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 EnvReg13Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg13Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg13Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg13Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg13Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg13Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg13Op EnvReg13Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg13Op EnvReg13Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg13Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg13Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg13Op EnvReg13Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg13Op EnvReg13Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg13Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg13Op EnvReg13Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg13Op EnvReg13Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg13Op::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); } EnvReg13Op EnvReg13Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg13Op EnvReg13Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg13Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg13Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg13Op EnvReg13Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg13Op EnvReg13Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg13Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg13Op EnvReg13Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg13Op EnvReg13Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg13Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg13Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg13Op EnvReg13Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg13Op EnvReg13Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg13Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg13Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg13Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg13Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg13Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg13Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg13Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg14Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg14OpGenericAdaptorBase::EnvReg14OpGenericAdaptorBase(EnvReg14Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg14OpAdaptor::EnvReg14OpAdaptor(EnvReg14Op op) : EnvReg14OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg14OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg14Op::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 EnvReg14Op::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 EnvReg14Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg14Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg14Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg14Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg14Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg14Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg14Op EnvReg14Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg14Op EnvReg14Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg14Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg14Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg14Op EnvReg14Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg14Op EnvReg14Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg14Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg14Op EnvReg14Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg14Op EnvReg14Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg14Op::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); } EnvReg14Op EnvReg14Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg14Op EnvReg14Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg14Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg14Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg14Op EnvReg14Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg14Op EnvReg14Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg14Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg14Op EnvReg14Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg14Op EnvReg14Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg14Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg14Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg14Op EnvReg14Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg14Op EnvReg14Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg14Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg14Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg14Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg14Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg14Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg14Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg14Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg15Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg15OpGenericAdaptorBase::EnvReg15OpGenericAdaptorBase(EnvReg15Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg15OpAdaptor::EnvReg15OpAdaptor(EnvReg15Op op) : EnvReg15OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg15OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg15Op::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 EnvReg15Op::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 EnvReg15Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg15Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg15Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg15Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg15Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg15Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg15Op EnvReg15Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg15Op EnvReg15Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg15Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg15Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg15Op EnvReg15Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg15Op EnvReg15Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg15Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg15Op EnvReg15Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg15Op EnvReg15Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg15Op::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); } EnvReg15Op EnvReg15Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg15Op EnvReg15Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg15Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg15Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg15Op EnvReg15Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg15Op EnvReg15Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg15Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg15Op EnvReg15Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg15Op EnvReg15Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg15Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg15Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg15Op EnvReg15Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg15Op EnvReg15Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg15Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg15Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg15Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg15Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg15Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg15Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg15Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg16Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg16OpGenericAdaptorBase::EnvReg16OpGenericAdaptorBase(EnvReg16Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg16OpAdaptor::EnvReg16OpAdaptor(EnvReg16Op op) : EnvReg16OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg16OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg16Op::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 EnvReg16Op::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 EnvReg16Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg16Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg16Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg16Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg16Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg16Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg16Op EnvReg16Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg16Op EnvReg16Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg16Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg16Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg16Op EnvReg16Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg16Op EnvReg16Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg16Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg16Op EnvReg16Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg16Op EnvReg16Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg16Op::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); } EnvReg16Op EnvReg16Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg16Op EnvReg16Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg16Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg16Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg16Op EnvReg16Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg16Op EnvReg16Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg16Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg16Op EnvReg16Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg16Op EnvReg16Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg16Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg16Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg16Op EnvReg16Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg16Op EnvReg16Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg16Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg16Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg16Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg16Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg16Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg16Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg16Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg17Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg17OpGenericAdaptorBase::EnvReg17OpGenericAdaptorBase(EnvReg17Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg17OpAdaptor::EnvReg17OpAdaptor(EnvReg17Op op) : EnvReg17OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg17OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg17Op::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 EnvReg17Op::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 EnvReg17Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg17Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg17Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg17Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg17Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg17Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg17Op EnvReg17Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg17Op EnvReg17Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg17Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg17Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg17Op EnvReg17Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg17Op EnvReg17Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg17Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg17Op EnvReg17Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg17Op EnvReg17Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg17Op::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); } EnvReg17Op EnvReg17Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg17Op EnvReg17Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg17Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg17Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg17Op EnvReg17Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg17Op EnvReg17Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg17Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg17Op EnvReg17Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg17Op EnvReg17Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg17Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg17Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg17Op EnvReg17Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg17Op EnvReg17Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg17Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg17Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg17Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg17Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg17Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg17Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg17Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg18Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg18OpGenericAdaptorBase::EnvReg18OpGenericAdaptorBase(EnvReg18Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg18OpAdaptor::EnvReg18OpAdaptor(EnvReg18Op op) : EnvReg18OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg18OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg18Op::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 EnvReg18Op::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 EnvReg18Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg18Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg18Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg18Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg18Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg18Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg18Op EnvReg18Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg18Op EnvReg18Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg18Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg18Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg18Op EnvReg18Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg18Op EnvReg18Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg18Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg18Op EnvReg18Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg18Op EnvReg18Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg18Op::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); } EnvReg18Op EnvReg18Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg18Op EnvReg18Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg18Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg18Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg18Op EnvReg18Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg18Op EnvReg18Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg18Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg18Op EnvReg18Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg18Op EnvReg18Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg18Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg18Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg18Op EnvReg18Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg18Op EnvReg18Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg18Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg18Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg18Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg18Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg18Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg18Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg18Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg19Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg19OpGenericAdaptorBase::EnvReg19OpGenericAdaptorBase(EnvReg19Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg19OpAdaptor::EnvReg19OpAdaptor(EnvReg19Op op) : EnvReg19OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg19OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg19Op::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 EnvReg19Op::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 EnvReg19Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg19Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg19Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg19Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg19Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg19Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg19Op EnvReg19Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg19Op EnvReg19Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg19Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg19Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg19Op EnvReg19Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg19Op EnvReg19Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg19Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg19Op EnvReg19Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg19Op EnvReg19Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg19Op::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); } EnvReg19Op EnvReg19Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg19Op EnvReg19Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg19Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg19Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg19Op EnvReg19Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg19Op EnvReg19Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg19Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg19Op EnvReg19Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg19Op EnvReg19Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg19Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg19Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg19Op EnvReg19Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg19Op EnvReg19Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg19Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg19Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg19Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg19Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg19Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg19Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg19Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg1Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg1OpGenericAdaptorBase::EnvReg1OpGenericAdaptorBase(EnvReg1Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg1OpAdaptor::EnvReg1OpAdaptor(EnvReg1Op op) : EnvReg1OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg1OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg1Op::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 EnvReg1Op::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 EnvReg1Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg1Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg1Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg1Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg1Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg1Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg1Op EnvReg1Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg1Op EnvReg1Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg1Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg1Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg1Op EnvReg1Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg1Op EnvReg1Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg1Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg1Op EnvReg1Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg1Op EnvReg1Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg1Op::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); } EnvReg1Op EnvReg1Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg1Op EnvReg1Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg1Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg1Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg1Op EnvReg1Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg1Op EnvReg1Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg1Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg1Op EnvReg1Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg1Op EnvReg1Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg1Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg1Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg1Op EnvReg1Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg1Op EnvReg1Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg1Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg1Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg1Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg1Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg1Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg1Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg1Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg20Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg20OpGenericAdaptorBase::EnvReg20OpGenericAdaptorBase(EnvReg20Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg20OpAdaptor::EnvReg20OpAdaptor(EnvReg20Op op) : EnvReg20OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg20OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg20Op::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 EnvReg20Op::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 EnvReg20Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg20Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg20Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg20Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg20Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg20Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg20Op EnvReg20Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg20Op EnvReg20Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg20Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg20Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg20Op EnvReg20Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg20Op EnvReg20Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg20Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg20Op EnvReg20Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg20Op EnvReg20Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg20Op::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); } EnvReg20Op EnvReg20Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg20Op EnvReg20Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg20Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg20Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg20Op EnvReg20Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg20Op EnvReg20Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg20Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg20Op EnvReg20Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg20Op EnvReg20Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg20Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg20Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg20Op EnvReg20Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg20Op EnvReg20Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg20Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg20Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg20Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg20Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg20Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg20Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg20Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg21Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg21OpGenericAdaptorBase::EnvReg21OpGenericAdaptorBase(EnvReg21Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg21OpAdaptor::EnvReg21OpAdaptor(EnvReg21Op op) : EnvReg21OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg21OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg21Op::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 EnvReg21Op::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 EnvReg21Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg21Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg21Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg21Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg21Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg21Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg21Op EnvReg21Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg21Op EnvReg21Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg21Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg21Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg21Op EnvReg21Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg21Op EnvReg21Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg21Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg21Op EnvReg21Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg21Op EnvReg21Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg21Op::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); } EnvReg21Op EnvReg21Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg21Op EnvReg21Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg21Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg21Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg21Op EnvReg21Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg21Op EnvReg21Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg21Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg21Op EnvReg21Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg21Op EnvReg21Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg21Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg21Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg21Op EnvReg21Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg21Op EnvReg21Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg21Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg21Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg21Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg21Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg21Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg21Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg21Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg22Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg22OpGenericAdaptorBase::EnvReg22OpGenericAdaptorBase(EnvReg22Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg22OpAdaptor::EnvReg22OpAdaptor(EnvReg22Op op) : EnvReg22OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg22OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg22Op::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 EnvReg22Op::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 EnvReg22Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg22Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg22Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg22Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg22Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg22Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg22Op EnvReg22Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg22Op EnvReg22Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg22Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg22Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg22Op EnvReg22Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg22Op EnvReg22Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg22Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg22Op EnvReg22Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg22Op EnvReg22Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg22Op::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); } EnvReg22Op EnvReg22Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg22Op EnvReg22Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg22Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg22Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg22Op EnvReg22Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg22Op EnvReg22Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg22Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg22Op EnvReg22Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg22Op EnvReg22Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg22Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg22Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg22Op EnvReg22Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg22Op EnvReg22Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg22Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg22Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg22Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg22Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg22Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg22Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg22Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg23Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg23OpGenericAdaptorBase::EnvReg23OpGenericAdaptorBase(EnvReg23Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg23OpAdaptor::EnvReg23OpAdaptor(EnvReg23Op op) : EnvReg23OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg23OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg23Op::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 EnvReg23Op::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 EnvReg23Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg23Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg23Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg23Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg23Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg23Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg23Op EnvReg23Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg23Op EnvReg23Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg23Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg23Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg23Op EnvReg23Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg23Op EnvReg23Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg23Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg23Op EnvReg23Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg23Op EnvReg23Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg23Op::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); } EnvReg23Op EnvReg23Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg23Op EnvReg23Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg23Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg23Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg23Op EnvReg23Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg23Op EnvReg23Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg23Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg23Op EnvReg23Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg23Op EnvReg23Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg23Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg23Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg23Op EnvReg23Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg23Op EnvReg23Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg23Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg23Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg23Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg23Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg23Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg23Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg23Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg24Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg24OpGenericAdaptorBase::EnvReg24OpGenericAdaptorBase(EnvReg24Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg24OpAdaptor::EnvReg24OpAdaptor(EnvReg24Op op) : EnvReg24OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg24OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg24Op::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 EnvReg24Op::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 EnvReg24Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg24Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg24Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg24Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg24Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg24Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg24Op EnvReg24Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg24Op EnvReg24Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg24Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg24Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg24Op EnvReg24Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg24Op EnvReg24Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg24Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg24Op EnvReg24Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg24Op EnvReg24Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg24Op::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); } EnvReg24Op EnvReg24Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg24Op EnvReg24Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg24Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg24Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg24Op EnvReg24Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg24Op EnvReg24Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg24Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg24Op EnvReg24Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg24Op EnvReg24Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg24Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg24Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg24Op EnvReg24Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg24Op EnvReg24Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg24Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg24Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg24Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg24Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg24Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg24Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg24Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg25Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg25OpGenericAdaptorBase::EnvReg25OpGenericAdaptorBase(EnvReg25Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg25OpAdaptor::EnvReg25OpAdaptor(EnvReg25Op op) : EnvReg25OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg25OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg25Op::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 EnvReg25Op::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 EnvReg25Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg25Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg25Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg25Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg25Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg25Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg25Op EnvReg25Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg25Op EnvReg25Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg25Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg25Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg25Op EnvReg25Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg25Op EnvReg25Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg25Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg25Op EnvReg25Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg25Op EnvReg25Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg25Op::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); } EnvReg25Op EnvReg25Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg25Op EnvReg25Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg25Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg25Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg25Op EnvReg25Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg25Op EnvReg25Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg25Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg25Op EnvReg25Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg25Op EnvReg25Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg25Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg25Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg25Op EnvReg25Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg25Op EnvReg25Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg25Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg25Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg25Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg25Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg25Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg25Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg25Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg26Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg26OpGenericAdaptorBase::EnvReg26OpGenericAdaptorBase(EnvReg26Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg26OpAdaptor::EnvReg26OpAdaptor(EnvReg26Op op) : EnvReg26OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg26OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg26Op::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 EnvReg26Op::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 EnvReg26Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg26Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg26Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg26Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg26Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg26Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg26Op EnvReg26Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg26Op EnvReg26Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg26Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg26Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg26Op EnvReg26Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg26Op EnvReg26Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg26Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg26Op EnvReg26Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg26Op EnvReg26Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg26Op::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); } EnvReg26Op EnvReg26Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg26Op EnvReg26Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg26Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg26Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg26Op EnvReg26Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg26Op EnvReg26Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg26Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg26Op EnvReg26Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg26Op EnvReg26Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg26Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg26Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg26Op EnvReg26Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg26Op EnvReg26Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg26Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg26Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg26Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg26Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg26Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg26Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg26Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg27Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg27OpGenericAdaptorBase::EnvReg27OpGenericAdaptorBase(EnvReg27Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg27OpAdaptor::EnvReg27OpAdaptor(EnvReg27Op op) : EnvReg27OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg27OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg27Op::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 EnvReg27Op::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 EnvReg27Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg27Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg27Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg27Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg27Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg27Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg27Op EnvReg27Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg27Op EnvReg27Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg27Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg27Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg27Op EnvReg27Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg27Op EnvReg27Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg27Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg27Op EnvReg27Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg27Op EnvReg27Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg27Op::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); } EnvReg27Op EnvReg27Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg27Op EnvReg27Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg27Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg27Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg27Op EnvReg27Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg27Op EnvReg27Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg27Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg27Op EnvReg27Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg27Op EnvReg27Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg27Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg27Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg27Op EnvReg27Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg27Op EnvReg27Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg27Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg27Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg27Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg27Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg27Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg27Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg27Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg28Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg28OpGenericAdaptorBase::EnvReg28OpGenericAdaptorBase(EnvReg28Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg28OpAdaptor::EnvReg28OpAdaptor(EnvReg28Op op) : EnvReg28OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg28OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg28Op::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 EnvReg28Op::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 EnvReg28Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg28Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg28Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg28Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg28Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg28Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg28Op EnvReg28Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg28Op EnvReg28Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg28Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg28Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg28Op EnvReg28Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg28Op EnvReg28Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg28Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg28Op EnvReg28Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg28Op EnvReg28Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg28Op::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); } EnvReg28Op EnvReg28Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg28Op EnvReg28Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg28Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg28Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg28Op EnvReg28Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg28Op EnvReg28Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg28Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg28Op EnvReg28Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg28Op EnvReg28Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg28Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg28Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg28Op EnvReg28Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg28Op EnvReg28Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg28Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg28Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg28Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg28Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg28Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg28Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg28Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg29Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg29OpGenericAdaptorBase::EnvReg29OpGenericAdaptorBase(EnvReg29Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg29OpAdaptor::EnvReg29OpAdaptor(EnvReg29Op op) : EnvReg29OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg29OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg29Op::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 EnvReg29Op::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 EnvReg29Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg29Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg29Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg29Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg29Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg29Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg29Op EnvReg29Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg29Op EnvReg29Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg29Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg29Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg29Op EnvReg29Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg29Op EnvReg29Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg29Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg29Op EnvReg29Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg29Op EnvReg29Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg29Op::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); } EnvReg29Op EnvReg29Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg29Op EnvReg29Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg29Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg29Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg29Op EnvReg29Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg29Op EnvReg29Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg29Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg29Op EnvReg29Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg29Op EnvReg29Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg29Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg29Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg29Op EnvReg29Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg29Op EnvReg29Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg29Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg29Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg29Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg29Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg29Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg29Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg29Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg2Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg2OpGenericAdaptorBase::EnvReg2OpGenericAdaptorBase(EnvReg2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg2OpAdaptor::EnvReg2OpAdaptor(EnvReg2Op op) : EnvReg2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg2OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg2Op::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 EnvReg2Op::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 EnvReg2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg2Op EnvReg2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg2Op EnvReg2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg2Op EnvReg2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg2Op EnvReg2Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg2Op EnvReg2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg2Op EnvReg2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg2Op::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); } EnvReg2Op EnvReg2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg2Op EnvReg2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg2Op EnvReg2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg2Op EnvReg2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg2Op EnvReg2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg2Op EnvReg2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg2Op EnvReg2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg2Op EnvReg2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg2Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg2Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg2Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg2Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg2Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg30Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg30OpGenericAdaptorBase::EnvReg30OpGenericAdaptorBase(EnvReg30Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg30OpAdaptor::EnvReg30OpAdaptor(EnvReg30Op op) : EnvReg30OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg30OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg30Op::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 EnvReg30Op::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 EnvReg30Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg30Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg30Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg30Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg30Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg30Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg30Op EnvReg30Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg30Op EnvReg30Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg30Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg30Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg30Op EnvReg30Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg30Op EnvReg30Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg30Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg30Op EnvReg30Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg30Op EnvReg30Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg30Op::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); } EnvReg30Op EnvReg30Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg30Op EnvReg30Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg30Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg30Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg30Op EnvReg30Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg30Op EnvReg30Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg30Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg30Op EnvReg30Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg30Op EnvReg30Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg30Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg30Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg30Op EnvReg30Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg30Op EnvReg30Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg30Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg30Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg30Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg30Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg30Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg30Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg30Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg31Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg31OpGenericAdaptorBase::EnvReg31OpGenericAdaptorBase(EnvReg31Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg31OpAdaptor::EnvReg31OpAdaptor(EnvReg31Op op) : EnvReg31OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg31OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg31Op::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 EnvReg31Op::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 EnvReg31Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg31Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg31Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg31Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg31Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg31Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg31Op EnvReg31Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg31Op EnvReg31Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg31Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg31Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg31Op EnvReg31Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg31Op EnvReg31Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg31Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg31Op EnvReg31Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg31Op EnvReg31Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg31Op::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); } EnvReg31Op EnvReg31Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg31Op EnvReg31Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg31Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg31Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg31Op EnvReg31Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg31Op EnvReg31Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg31Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg31Op EnvReg31Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg31Op EnvReg31Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg31Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg31Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg31Op EnvReg31Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg31Op EnvReg31Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg31Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg31Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg31Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg31Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg31Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg31Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg31Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg3Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg3OpGenericAdaptorBase::EnvReg3OpGenericAdaptorBase(EnvReg3Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg3OpAdaptor::EnvReg3OpAdaptor(EnvReg3Op op) : EnvReg3OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg3OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg3Op::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 EnvReg3Op::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 EnvReg3Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg3Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg3Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg3Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg3Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg3Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg3Op EnvReg3Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg3Op EnvReg3Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg3Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg3Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg3Op EnvReg3Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg3Op EnvReg3Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg3Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg3Op EnvReg3Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg3Op EnvReg3Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg3Op::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); } EnvReg3Op EnvReg3Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg3Op EnvReg3Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg3Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg3Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg3Op EnvReg3Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg3Op EnvReg3Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg3Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg3Op EnvReg3Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg3Op EnvReg3Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg3Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg3Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg3Op EnvReg3Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg3Op EnvReg3Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg3Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg3Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg3Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg3Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg3Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg3Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg3Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg4Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg4OpGenericAdaptorBase::EnvReg4OpGenericAdaptorBase(EnvReg4Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg4OpAdaptor::EnvReg4OpAdaptor(EnvReg4Op op) : EnvReg4OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg4OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg4Op::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 EnvReg4Op::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 EnvReg4Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg4Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg4Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg4Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg4Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg4Op EnvReg4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg4Op EnvReg4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg4Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg4Op EnvReg4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg4Op EnvReg4Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg4Op EnvReg4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg4Op EnvReg4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg4Op::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); } EnvReg4Op EnvReg4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg4Op EnvReg4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg4Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg4Op EnvReg4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg4Op EnvReg4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg4Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg4Op EnvReg4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg4Op EnvReg4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg4Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg4Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg4Op EnvReg4Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg4Op EnvReg4Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg4Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg4Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg4Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg4Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg4Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg4Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg4Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg5Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg5OpGenericAdaptorBase::EnvReg5OpGenericAdaptorBase(EnvReg5Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg5OpAdaptor::EnvReg5OpAdaptor(EnvReg5Op op) : EnvReg5OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg5OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg5Op::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 EnvReg5Op::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 EnvReg5Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg5Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg5Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg5Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg5Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg5Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg5Op EnvReg5Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg5Op EnvReg5Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg5Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg5Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg5Op EnvReg5Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg5Op EnvReg5Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg5Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg5Op EnvReg5Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg5Op EnvReg5Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg5Op::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); } EnvReg5Op EnvReg5Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg5Op EnvReg5Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg5Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg5Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg5Op EnvReg5Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg5Op EnvReg5Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg5Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg5Op EnvReg5Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg5Op EnvReg5Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg5Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg5Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg5Op EnvReg5Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg5Op EnvReg5Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg5Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg5Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg5Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg5Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg5Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg5Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg5Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg6Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg6OpGenericAdaptorBase::EnvReg6OpGenericAdaptorBase(EnvReg6Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg6OpAdaptor::EnvReg6OpAdaptor(EnvReg6Op op) : EnvReg6OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg6OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg6Op::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 EnvReg6Op::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 EnvReg6Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg6Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg6Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg6Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg6Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg6Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg6Op EnvReg6Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg6Op EnvReg6Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg6Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg6Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg6Op EnvReg6Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg6Op EnvReg6Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg6Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg6Op EnvReg6Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg6Op EnvReg6Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg6Op::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); } EnvReg6Op EnvReg6Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg6Op EnvReg6Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg6Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg6Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg6Op EnvReg6Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg6Op EnvReg6Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg6Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg6Op EnvReg6Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg6Op EnvReg6Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg6Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg6Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg6Op EnvReg6Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg6Op EnvReg6Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg6Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg6Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg6Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg6Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg6Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg6Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg6Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg7Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg7OpGenericAdaptorBase::EnvReg7OpGenericAdaptorBase(EnvReg7Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg7OpAdaptor::EnvReg7OpAdaptor(EnvReg7Op op) : EnvReg7OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg7OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg7Op::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 EnvReg7Op::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 EnvReg7Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg7Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg7Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg7Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg7Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg7Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg7Op EnvReg7Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg7Op EnvReg7Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg7Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg7Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg7Op EnvReg7Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg7Op EnvReg7Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg7Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg7Op EnvReg7Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg7Op EnvReg7Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg7Op::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); } EnvReg7Op EnvReg7Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg7Op EnvReg7Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg7Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg7Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg7Op EnvReg7Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg7Op EnvReg7Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg7Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg7Op EnvReg7Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg7Op EnvReg7Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg7Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg7Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg7Op EnvReg7Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg7Op EnvReg7Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg7Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg7Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg7Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg7Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg7Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg7Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg7Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg8Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg8OpGenericAdaptorBase::EnvReg8OpGenericAdaptorBase(EnvReg8Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg8OpAdaptor::EnvReg8OpAdaptor(EnvReg8Op op) : EnvReg8OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg8OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg8Op::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 EnvReg8Op::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 EnvReg8Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg8Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg8Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg8Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg8Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg8Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg8Op EnvReg8Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg8Op EnvReg8Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg8Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg8Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg8Op EnvReg8Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg8Op EnvReg8Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg8Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg8Op EnvReg8Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg8Op EnvReg8Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg8Op::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); } EnvReg8Op EnvReg8Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg8Op EnvReg8Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg8Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg8Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg8Op EnvReg8Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg8Op EnvReg8Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg8Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg8Op EnvReg8Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg8Op EnvReg8Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg8Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg8Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg8Op EnvReg8Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg8Op EnvReg8Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg8Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg8Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg8Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg8Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg8Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg8Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg8Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::EnvReg9Op definitions //===----------------------------------------------------------------------===// namespace detail { EnvReg9OpGenericAdaptorBase::EnvReg9OpGenericAdaptorBase(EnvReg9Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail EnvReg9OpAdaptor::EnvReg9OpAdaptor(EnvReg9Op op) : EnvReg9OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnvReg9OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult EnvReg9Op::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 EnvReg9Op::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 EnvReg9Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional EnvReg9Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void EnvReg9Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void EnvReg9Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult EnvReg9Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void EnvReg9Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } EnvReg9Op EnvReg9Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg9Op EnvReg9Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void EnvReg9Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg9Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } EnvReg9Op EnvReg9Op::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg9Op EnvReg9Op::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void EnvReg9Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnvReg9Op EnvReg9Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg9Op EnvReg9Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void EnvReg9Op::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); } EnvReg9Op EnvReg9Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg9Op EnvReg9Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void EnvReg9Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg9Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg9Op EnvReg9Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg9Op EnvReg9Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void EnvReg9Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnvReg9Op EnvReg9Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg9Op EnvReg9Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void EnvReg9Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(EnvReg9Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } EnvReg9Op EnvReg9Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnvReg9Op EnvReg9Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult EnvReg9Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnvReg9Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult EnvReg9Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult EnvReg9Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void EnvReg9Op::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void EnvReg9Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::EnvReg9Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Ex2Op definitions //===----------------------------------------------------------------------===// namespace detail { Ex2OpGenericAdaptorBase::Ex2OpGenericAdaptorBase(Ex2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::BoolAttr Ex2OpGenericAdaptorBase::getFtzAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().ftz); return attr; } bool Ex2OpGenericAdaptorBase::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } } // namespace detail Ex2OpAdaptor::Ex2OpAdaptor(Ex2Op op) : Ex2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Ex2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; if (tblgen_ftz && !((::llvm::isa<::mlir::BoolAttr>(tblgen_ftz)))) return emitError(loc, "'nvvm.ex2' op attribute 'ftz' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult Ex2Op::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.ftz; auto attr = dict.get("ftz"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ftz` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Ex2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.ftz; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ftz", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Ex2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.ftz.getAsOpaquePointer())); } std::optional Ex2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "ftz") return prop.ftz; return std::nullopt; } void Ex2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "ftz") { prop.ftz = ::llvm::dyn_cast_or_null>(value); return; } } void Ex2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.ftz) attrs.append("ftz", prop.ftz); } ::llvm::LogicalResult Ex2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFtzAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "ftz", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Ex2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.ftz))) return ::mlir::failure(); return ::mlir::success(); } void Ex2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.ftz); } bool Ex2Op::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } void Ex2Op::setFtz(bool attrValue) { getProperties().ftz = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void Ex2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } odsState.addTypes(res); } Ex2Op Ex2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Ex2Op Ex2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(src), std::forward(ftz)); } void Ex2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(Ex2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } Ex2Op Ex2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Ex2Op Ex2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(src), std::forward(ftz)); } void Ex2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } Ex2Op Ex2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Ex2Op Ex2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(ftz)); } void Ex2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); odsState.addTypes(res); } Ex2Op Ex2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Ex2Op Ex2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(src), std::forward(ftz)); } void Ex2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(Ex2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } Ex2Op Ex2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Ex2Op Ex2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(src), std::forward(ftz)); } void Ex2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } Ex2Op Ex2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Ex2Op Ex2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(ftz)); } void Ex2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Ex2Op Ex2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Ex2Op Ex2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Ex2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(Ex2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } Ex2Op Ex2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Ex2Op Ex2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void Ex2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Ex2Op Ex2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Ex2Op Ex2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Ex2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(Ex2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } Ex2Op Ex2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Ex2Op Ex2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Ex2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.ftz) properties.ftz = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult Ex2Op::verifyInvariantsImpl() { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_ftz, "ftz"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*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_NVVMOps13(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Ex2Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult Ex2Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); if (operands.size() <= 0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[0].getType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult Ex2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) 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::FloatType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } result.addTypes(srcTypes[0]); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void Ex2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFtzAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("ftz"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::FloatType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void Ex2Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Ex2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Ex2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Exit definitions //===----------------------------------------------------------------------===// namespace detail { ExitGenericAdaptorBase::ExitGenericAdaptorBase(Exit op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail ExitAdaptor::ExitAdaptor(Exit op) : ExitGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ExitAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult Exit::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 Exit::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 Exit::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional Exit::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void Exit::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void Exit::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult Exit::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void Exit::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { } Exit Exit::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Exit Exit::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void Exit::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Exit Exit::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Exit Exit::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void Exit::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); } Exit Exit::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Exit Exit::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Exit::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Exit Exit::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Exit Exit::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult Exit::verifyInvariantsImpl() { return ::mlir::success(); } ::llvm::LogicalResult Exit::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult Exit::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 Exit::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Exit) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::FenceMbarrierInitOp definitions //===----------------------------------------------------------------------===// namespace detail { FenceMbarrierInitOpGenericAdaptorBase::FenceMbarrierInitOpGenericAdaptorBase(FenceMbarrierInitOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail FenceMbarrierInitOpAdaptor::FenceMbarrierInitOpAdaptor(FenceMbarrierInitOp op) : FenceMbarrierInitOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult FenceMbarrierInitOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult FenceMbarrierInitOp::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 FenceMbarrierInitOp::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 FenceMbarrierInitOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional FenceMbarrierInitOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void FenceMbarrierInitOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void FenceMbarrierInitOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult FenceMbarrierInitOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void FenceMbarrierInitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { } FenceMbarrierInitOp FenceMbarrierInitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceMbarrierInitOp FenceMbarrierInitOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void FenceMbarrierInitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } FenceMbarrierInitOp FenceMbarrierInitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceMbarrierInitOp FenceMbarrierInitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void FenceMbarrierInitOp::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); } FenceMbarrierInitOp FenceMbarrierInitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceMbarrierInitOp FenceMbarrierInitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void FenceMbarrierInitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } FenceMbarrierInitOp FenceMbarrierInitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceMbarrierInitOp FenceMbarrierInitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult FenceMbarrierInitOp::verifyInvariantsImpl() { return ::mlir::success(); } ::llvm::LogicalResult FenceMbarrierInitOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult FenceMbarrierInitOp::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 FenceMbarrierInitOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::FenceMbarrierInitOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::FenceProxyAcquireOp definitions //===----------------------------------------------------------------------===// namespace detail { FenceProxyAcquireOpGenericAdaptorBase::FenceProxyAcquireOpGenericAdaptorBase(FenceProxyAcquireOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::MemScopeKind FenceProxyAcquireOpGenericAdaptorBase::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } ::mlir::NVVM::ProxyKindAttr FenceProxyAcquireOpGenericAdaptorBase::getFromProxyAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::ProxyKindAttr>(getProperties().fromProxy); return attr; } ::mlir::NVVM::ProxyKind FenceProxyAcquireOpGenericAdaptorBase::getFromProxy() { auto attr = getFromProxyAttr(); return attr.getValue(); } ::mlir::NVVM::ProxyKindAttr FenceProxyAcquireOpGenericAdaptorBase::getToProxyAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::ProxyKindAttr>(getProperties().toProxy); return attr; } ::mlir::NVVM::ProxyKind FenceProxyAcquireOpGenericAdaptorBase::getToProxy() { auto attr = getToProxyAttr(); return attr.getValue(); } } // namespace detail FenceProxyAcquireOpAdaptor::FenceProxyAcquireOpAdaptor(FenceProxyAcquireOp op) : FenceProxyAcquireOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult FenceProxyAcquireOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fromProxy = getProperties().fromProxy; (void)tblgen_fromProxy; auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (!tblgen_scope) return emitError(loc, "'nvvm.fence.proxy.acquire' op requires attribute 'scope'"); auto tblgen_toProxy = getProperties().toProxy; (void)tblgen_toProxy; if (tblgen_scope && !((::llvm::isa<::mlir::NVVM::MemScopeKindAttr>(tblgen_scope)))) return emitError(loc, "'nvvm.fence.proxy.acquire' op attribute 'scope' failed to satisfy constraint: NVVM Memory Scope kind"); if (tblgen_fromProxy && !((::llvm::isa<::mlir::NVVM::ProxyKindAttr>(tblgen_fromProxy)))) return emitError(loc, "'nvvm.fence.proxy.acquire' op attribute 'fromProxy' failed to satisfy constraint: Proxy kind"); if (tblgen_toProxy && !((::llvm::isa<::mlir::NVVM::ProxyKindAttr>(tblgen_toProxy)))) return emitError(loc, "'nvvm.fence.proxy.acquire' op attribute 'toProxy' failed to satisfy constraint: Proxy kind"); return ::mlir::success(); } ::llvm::LogicalResult FenceProxyAcquireOp::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.fromProxy; auto attr = dict.get("fromProxy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fromProxy` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.scope; auto attr = dict.get("scope"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scope` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.toProxy; auto attr = dict.get("toProxy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `toProxy` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute FenceProxyAcquireOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fromProxy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fromProxy", propStorage)); } { const auto &propStorage = prop.scope; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("scope", propStorage)); } { const auto &propStorage = prop.toProxy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("toProxy", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code FenceProxyAcquireOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fromProxy.getAsOpaquePointer()), llvm::hash_value(prop.scope.getAsOpaquePointer()), llvm::hash_value(prop.toProxy.getAsOpaquePointer())); } std::optional FenceProxyAcquireOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fromProxy") return prop.fromProxy; if (name == "scope") return prop.scope; if (name == "toProxy") return prop.toProxy; return std::nullopt; } void FenceProxyAcquireOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fromProxy") { prop.fromProxy = ::llvm::dyn_cast_or_null>(value); return; } if (name == "scope") { prop.scope = ::llvm::dyn_cast_or_null>(value); return; } if (name == "toProxy") { prop.toProxy = ::llvm::dyn_cast_or_null>(value); return; } } void FenceProxyAcquireOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fromProxy) attrs.append("fromProxy", prop.fromProxy); if (prop.scope) attrs.append("scope", prop.scope); if (prop.toProxy) attrs.append("toProxy", prop.toProxy); } ::llvm::LogicalResult FenceProxyAcquireOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFromProxyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps28(attr, "fromProxy", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getScopeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(attr, "scope", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getToProxyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps28(attr, "toProxy", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult FenceProxyAcquireOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fromProxy))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.scope))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.toProxy))) return ::mlir::failure(); return ::mlir::success(); } void FenceProxyAcquireOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fromProxy); writer.writeAttribute(prop.scope); writer.writeOptionalAttribute(prop.toProxy); } ::mlir::NVVM::MemScopeKind FenceProxyAcquireOp::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } ::mlir::NVVM::ProxyKind FenceProxyAcquireOp::getFromProxy() { auto attr = getFromProxyAttr(); return attr.getValue(); } ::mlir::NVVM::ProxyKind FenceProxyAcquireOp::getToProxy() { auto attr = getToProxyAttr(); return attr.getValue(); } void FenceProxyAcquireOp::setScope(::mlir::NVVM::MemScopeKind attrValue) { getProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FenceProxyAcquireOp::setFromProxy(::mlir::NVVM::ProxyKind attrValue) { getProperties().fromProxy = ::mlir::NVVM::ProxyKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FenceProxyAcquireOp::setToProxy(::mlir::NVVM::ProxyKind attrValue) { getProperties().toProxy = ::mlir::NVVM::ProxyKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FenceProxyAcquireOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::Value addr, ::mlir::Value size, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { odsState.addOperands(addr); odsState.addOperands(size); odsState.getOrAddProperties().scope = scope; if (fromProxy) { odsState.getOrAddProperties().fromProxy = fromProxy; } if (toProxy) { odsState.getOrAddProperties().toProxy = toProxy; } } FenceProxyAcquireOp FenceProxyAcquireOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::Value addr, ::mlir::Value size, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(scope), std::forward(addr), std::forward(size), std::forward(fromProxy), std::forward(toProxy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyAcquireOp FenceProxyAcquireOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::Value addr, ::mlir::Value size, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { return create(builder, builder.getLoc(), std::forward(scope), std::forward(addr), std::forward(size), std::forward(fromProxy), std::forward(toProxy)); } void FenceProxyAcquireOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::Value addr, ::mlir::Value size, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { odsState.addOperands(addr); odsState.addOperands(size); odsState.getOrAddProperties().scope = scope; if (fromProxy) { odsState.getOrAddProperties().fromProxy = fromProxy; } if (toProxy) { odsState.getOrAddProperties().toProxy = toProxy; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } FenceProxyAcquireOp FenceProxyAcquireOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::Value addr, ::mlir::Value size, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(scope), std::forward(addr), std::forward(size), std::forward(fromProxy), std::forward(toProxy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyAcquireOp FenceProxyAcquireOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::Value addr, ::mlir::Value size, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(scope), std::forward(addr), std::forward(size), std::forward(fromProxy), std::forward(toProxy)); } void FenceProxyAcquireOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::MemScopeKind scope, ::mlir::Value addr, ::mlir::Value size, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { odsState.addOperands(addr); odsState.addOperands(size); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().fromProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), fromProxy); odsState.getOrAddProperties().toProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), toProxy); } FenceProxyAcquireOp FenceProxyAcquireOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::MemScopeKind scope, ::mlir::Value addr, ::mlir::Value size, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(scope), std::forward(addr), std::forward(size), std::forward(fromProxy), std::forward(toProxy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyAcquireOp FenceProxyAcquireOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::MemScopeKind scope, ::mlir::Value addr, ::mlir::Value size, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { return create(builder, builder.getLoc(), std::forward(scope), std::forward(addr), std::forward(size), std::forward(fromProxy), std::forward(toProxy)); } void FenceProxyAcquireOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKind scope, ::mlir::Value addr, ::mlir::Value size, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { odsState.addOperands(addr); odsState.addOperands(size); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().fromProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), fromProxy); odsState.getOrAddProperties().toProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), toProxy); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } FenceProxyAcquireOp FenceProxyAcquireOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKind scope, ::mlir::Value addr, ::mlir::Value size, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(scope), std::forward(addr), std::forward(size), std::forward(fromProxy), std::forward(toProxy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyAcquireOp FenceProxyAcquireOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKind scope, ::mlir::Value addr, ::mlir::Value size, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(scope), std::forward(addr), std::forward(size), std::forward(fromProxy), std::forward(toProxy)); } void FenceProxyAcquireOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } FenceProxyAcquireOp FenceProxyAcquireOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyAcquireOp FenceProxyAcquireOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void FenceProxyAcquireOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } FenceProxyAcquireOp FenceProxyAcquireOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyAcquireOp FenceProxyAcquireOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void FenceProxyAcquireOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.fromProxy) properties.fromProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), ProxyKind::GENERIC); if (!properties.toProxy) properties.toProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), ProxyKind::TENSORMAP); } ::llvm::LogicalResult FenceProxyAcquireOp::verifyInvariantsImpl() { auto tblgen_fromProxy = getProperties().fromProxy; (void)tblgen_fromProxy; auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (!tblgen_scope) return emitOpError("requires attribute 'scope'"); auto tblgen_toProxy = getProperties().toProxy; (void)tblgen_toProxy; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(*this, tblgen_scope, "scope"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps28(*this, tblgen_fromProxy, "fromProxy"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps28(*this, tblgen_toProxy, "toProxy"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps20(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult FenceProxyAcquireOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult FenceProxyAcquireOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::MemScopeKindAttr scopeAttr; ::mlir::OpAsmParser::UnresolvedOperand addrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> addrOperands(&addrRawOperand, 1); ::llvm::SMLoc addrOperandsLoc; (void)addrOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand sizeRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sizeOperands(&sizeRawOperand, 1); ::llvm::SMLoc sizeOperandsLoc; (void)sizeOperandsLoc; ::mlir::NVVM::ProxyKindAttr fromProxyAttr; ::mlir::NVVM::ProxyKindAttr toProxyAttr; if (parser.parseCustomAttributeWithFallback(scopeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (scopeAttr) result.getOrAddProperties().scope = scopeAttr; addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); sizeOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sizeRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("from_proxy"))) { if (parser.parseEqual()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(fromProxyAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fromProxyAttr) result.getOrAddProperties().fromProxy = fromProxyAttr; } if (::mlir::succeeded(parser.parseOptionalKeyword("to_proxy"))) { if (parser.parseEqual()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(toProxyAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (toProxyAttr) result.getOrAddProperties().toProxy = toProxyAttr; } { 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::LLVM::LLVMPointerType>(0); ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(32); if (parser.resolveOperands(addrOperands, odsBuildableType0, addrOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(sizeOperands, odsBuildableType1, sizeOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void FenceProxyAcquireOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getScopeAttr()); _odsPrinter << ' '; _odsPrinter << getAddr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSize(); if (getFromProxyAttr() != ::mlir::NVVM::ProxyKindAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ProxyKind::GENERIC)) { _odsPrinter << ' ' << "from_proxy"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getFromProxyAttr()); } if (getToProxyAttr() != ::mlir::NVVM::ProxyKindAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ProxyKind::TENSORMAP)) { _odsPrinter << ' ' << "to_proxy"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getToProxyAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("scope"); elidedAttrs.push_back("fromProxy"); elidedAttrs.push_back("toProxy"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFromProxyAttr(); if(attr && (attr == ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), ProxyKind::GENERIC))) elidedAttrs.push_back("fromProxy"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getToProxyAttr(); if(attr && (attr == ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), ProxyKind::TENSORMAP))) elidedAttrs.push_back("toProxy"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::FenceProxyAcquireOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::FenceProxyAcquireOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::FenceProxyOp definitions //===----------------------------------------------------------------------===// namespace detail { FenceProxyOpGenericAdaptorBase::FenceProxyOpGenericAdaptorBase(FenceProxyOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::ProxyKind FenceProxyOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::std::optional<::mlir::NVVM::SharedSpace> FenceProxyOpGenericAdaptorBase::getSpace() { auto attr = getSpaceAttr(); return attr ? ::std::optional<::mlir::NVVM::SharedSpace>(attr.getValue()) : (::std::nullopt); } } // namespace detail FenceProxyOpAdaptor::FenceProxyOpAdaptor(FenceProxyOp op) : FenceProxyOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult FenceProxyOpAdaptor::verify(::mlir::Location loc) { auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'nvvm.fence.proxy' op requires attribute 'kind'"); auto tblgen_space = getProperties().space; (void)tblgen_space; if (tblgen_kind && !(((::llvm::isa<::mlir::NVVM::ProxyKindAttr>(tblgen_kind))) && (!(((::llvm::cast<::mlir::NVVM::ProxyKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::ProxyKind::TENSORMAP)) || ((::llvm::cast<::mlir::NVVM::ProxyKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::ProxyKind::GENERIC)))))) return emitError(loc, "'nvvm.fence.proxy' op attribute 'kind' failed to satisfy constraint: Proxy kind whose value is none of {tensormap, generic}"); if (tblgen_space && !((::llvm::isa<::mlir::NVVM::SharedSpaceAttr>(tblgen_space)))) return emitError(loc, "'nvvm.fence.proxy' op attribute 'space' failed to satisfy constraint: Shared memory space"); return ::mlir::success(); } ::llvm::LogicalResult FenceProxyOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.space; auto attr = dict.get("space"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `space` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute FenceProxyOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", propStorage)); } { const auto &propStorage = prop.space; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("space", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code FenceProxyOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.kind.getAsOpaquePointer()), llvm::hash_value(prop.space.getAsOpaquePointer())); } std::optional FenceProxyOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "kind") return prop.kind; if (name == "space") return prop.space; return std::nullopt; } void FenceProxyOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } if (name == "space") { prop.space = ::llvm::dyn_cast_or_null>(value); return; } } void FenceProxyOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.kind) attrs.append("kind", prop.kind); if (prop.space) attrs.append("space", prop.space); } ::llvm::LogicalResult FenceProxyOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps29(attr, "kind", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSpaceAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps30(attr, "space", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult FenceProxyOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.kind))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.space))) return ::mlir::failure(); return ::mlir::success(); } void FenceProxyOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.kind); writer.writeOptionalAttribute(prop.space); } ::mlir::NVVM::ProxyKind FenceProxyOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::std::optional<::mlir::NVVM::SharedSpace> FenceProxyOp::getSpace() { auto attr = getSpaceAttr(); return attr ? ::std::optional<::mlir::NVVM::SharedSpace>(attr.getValue()) : (::std::nullopt); } void FenceProxyOp::setKind(::mlir::NVVM::ProxyKind attrValue) { getProperties().kind = ::mlir::NVVM::ProxyKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FenceProxyOp::setSpace(::std::optional<::mlir::NVVM::SharedSpace> attrValue) { auto &odsProp = getProperties().space; if (attrValue) odsProp = ::mlir::NVVM::SharedSpaceAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void FenceProxyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::ProxyKindAttr kind, /*optional*/::mlir::NVVM::SharedSpaceAttr space) { odsState.getOrAddProperties().kind = kind; if (space) { odsState.getOrAddProperties().space = space; } } FenceProxyOp FenceProxyOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::ProxyKindAttr kind, /*optional*/::mlir::NVVM::SharedSpaceAttr space) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind), std::forward(space)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyOp FenceProxyOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::ProxyKindAttr kind, /*optional*/::mlir::NVVM::SharedSpaceAttr space) { return create(builder, builder.getLoc(), std::forward(kind), std::forward(space)); } void FenceProxyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::ProxyKindAttr kind, /*optional*/::mlir::NVVM::SharedSpaceAttr space) { odsState.getOrAddProperties().kind = kind; if (space) { odsState.getOrAddProperties().space = space; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } FenceProxyOp FenceProxyOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::ProxyKindAttr kind, /*optional*/::mlir::NVVM::SharedSpaceAttr space) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind), std::forward(space)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyOp FenceProxyOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::ProxyKindAttr kind, /*optional*/::mlir::NVVM::SharedSpaceAttr space) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind), std::forward(space)); } void FenceProxyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::ProxyKind kind, /*optional*/::mlir::NVVM::SharedSpaceAttr space) { odsState.getOrAddProperties().kind = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), kind); if (space) { odsState.getOrAddProperties().space = space; } } FenceProxyOp FenceProxyOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::ProxyKind kind, /*optional*/::mlir::NVVM::SharedSpaceAttr space) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind), std::forward(space)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyOp FenceProxyOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::ProxyKind kind, /*optional*/::mlir::NVVM::SharedSpaceAttr space) { return create(builder, builder.getLoc(), std::forward(kind), std::forward(space)); } void FenceProxyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::ProxyKind kind, /*optional*/::mlir::NVVM::SharedSpaceAttr space) { odsState.getOrAddProperties().kind = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), kind); if (space) { odsState.getOrAddProperties().space = space; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } FenceProxyOp FenceProxyOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::ProxyKind kind, /*optional*/::mlir::NVVM::SharedSpaceAttr space) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind), std::forward(space)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyOp FenceProxyOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::ProxyKind kind, /*optional*/::mlir::NVVM::SharedSpaceAttr space) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind), std::forward(space)); } void FenceProxyOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } FenceProxyOp FenceProxyOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyOp FenceProxyOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void FenceProxyOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } FenceProxyOp FenceProxyOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyOp FenceProxyOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult FenceProxyOp::verifyInvariantsImpl() { auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); auto tblgen_space = getProperties().space; (void)tblgen_space; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps29(*this, tblgen_kind, "kind"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps30(*this, tblgen_space, "space"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult FenceProxyOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult FenceProxyOp::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 FenceProxyOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::FenceProxyOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::FenceProxyOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::FenceProxyReleaseOp definitions //===----------------------------------------------------------------------===// namespace detail { FenceProxyReleaseOpGenericAdaptorBase::FenceProxyReleaseOpGenericAdaptorBase(FenceProxyReleaseOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::MemScopeKind FenceProxyReleaseOpGenericAdaptorBase::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } ::mlir::NVVM::ProxyKindAttr FenceProxyReleaseOpGenericAdaptorBase::getFromProxyAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::ProxyKindAttr>(getProperties().fromProxy); return attr; } ::mlir::NVVM::ProxyKind FenceProxyReleaseOpGenericAdaptorBase::getFromProxy() { auto attr = getFromProxyAttr(); return attr.getValue(); } ::mlir::NVVM::ProxyKindAttr FenceProxyReleaseOpGenericAdaptorBase::getToProxyAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::ProxyKindAttr>(getProperties().toProxy); return attr; } ::mlir::NVVM::ProxyKind FenceProxyReleaseOpGenericAdaptorBase::getToProxy() { auto attr = getToProxyAttr(); return attr.getValue(); } } // namespace detail FenceProxyReleaseOpAdaptor::FenceProxyReleaseOpAdaptor(FenceProxyReleaseOp op) : FenceProxyReleaseOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult FenceProxyReleaseOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fromProxy = getProperties().fromProxy; (void)tblgen_fromProxy; auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (!tblgen_scope) return emitError(loc, "'nvvm.fence.proxy.release' op requires attribute 'scope'"); auto tblgen_toProxy = getProperties().toProxy; (void)tblgen_toProxy; if (tblgen_scope && !((::llvm::isa<::mlir::NVVM::MemScopeKindAttr>(tblgen_scope)))) return emitError(loc, "'nvvm.fence.proxy.release' op attribute 'scope' failed to satisfy constraint: NVVM Memory Scope kind"); if (tblgen_fromProxy && !((::llvm::isa<::mlir::NVVM::ProxyKindAttr>(tblgen_fromProxy)))) return emitError(loc, "'nvvm.fence.proxy.release' op attribute 'fromProxy' failed to satisfy constraint: Proxy kind"); if (tblgen_toProxy && !((::llvm::isa<::mlir::NVVM::ProxyKindAttr>(tblgen_toProxy)))) return emitError(loc, "'nvvm.fence.proxy.release' op attribute 'toProxy' failed to satisfy constraint: Proxy kind"); return ::mlir::success(); } ::llvm::LogicalResult FenceProxyReleaseOp::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.fromProxy; auto attr = dict.get("fromProxy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fromProxy` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.scope; auto attr = dict.get("scope"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scope` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.toProxy; auto attr = dict.get("toProxy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `toProxy` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute FenceProxyReleaseOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fromProxy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fromProxy", propStorage)); } { const auto &propStorage = prop.scope; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("scope", propStorage)); } { const auto &propStorage = prop.toProxy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("toProxy", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code FenceProxyReleaseOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fromProxy.getAsOpaquePointer()), llvm::hash_value(prop.scope.getAsOpaquePointer()), llvm::hash_value(prop.toProxy.getAsOpaquePointer())); } std::optional FenceProxyReleaseOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fromProxy") return prop.fromProxy; if (name == "scope") return prop.scope; if (name == "toProxy") return prop.toProxy; return std::nullopt; } void FenceProxyReleaseOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fromProxy") { prop.fromProxy = ::llvm::dyn_cast_or_null>(value); return; } if (name == "scope") { prop.scope = ::llvm::dyn_cast_or_null>(value); return; } if (name == "toProxy") { prop.toProxy = ::llvm::dyn_cast_or_null>(value); return; } } void FenceProxyReleaseOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fromProxy) attrs.append("fromProxy", prop.fromProxy); if (prop.scope) attrs.append("scope", prop.scope); if (prop.toProxy) attrs.append("toProxy", prop.toProxy); } ::llvm::LogicalResult FenceProxyReleaseOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFromProxyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps28(attr, "fromProxy", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getScopeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(attr, "scope", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getToProxyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps28(attr, "toProxy", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult FenceProxyReleaseOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fromProxy))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.scope))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.toProxy))) return ::mlir::failure(); return ::mlir::success(); } void FenceProxyReleaseOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fromProxy); writer.writeAttribute(prop.scope); writer.writeOptionalAttribute(prop.toProxy); } ::mlir::NVVM::MemScopeKind FenceProxyReleaseOp::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } ::mlir::NVVM::ProxyKind FenceProxyReleaseOp::getFromProxy() { auto attr = getFromProxyAttr(); return attr.getValue(); } ::mlir::NVVM::ProxyKind FenceProxyReleaseOp::getToProxy() { auto attr = getToProxyAttr(); return attr.getValue(); } void FenceProxyReleaseOp::setScope(::mlir::NVVM::MemScopeKind attrValue) { getProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FenceProxyReleaseOp::setFromProxy(::mlir::NVVM::ProxyKind attrValue) { getProperties().fromProxy = ::mlir::NVVM::ProxyKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FenceProxyReleaseOp::setToProxy(::mlir::NVVM::ProxyKind attrValue) { getProperties().toProxy = ::mlir::NVVM::ProxyKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FenceProxyReleaseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { odsState.getOrAddProperties().scope = scope; if (fromProxy) { odsState.getOrAddProperties().fromProxy = fromProxy; } if (toProxy) { odsState.getOrAddProperties().toProxy = toProxy; } } FenceProxyReleaseOp FenceProxyReleaseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(scope), std::forward(fromProxy), std::forward(toProxy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyReleaseOp FenceProxyReleaseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { return create(builder, builder.getLoc(), std::forward(scope), std::forward(fromProxy), std::forward(toProxy)); } void FenceProxyReleaseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { odsState.getOrAddProperties().scope = scope; if (fromProxy) { odsState.getOrAddProperties().fromProxy = fromProxy; } if (toProxy) { odsState.getOrAddProperties().toProxy = toProxy; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } FenceProxyReleaseOp FenceProxyReleaseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(scope), std::forward(fromProxy), std::forward(toProxy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyReleaseOp FenceProxyReleaseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(scope), std::forward(fromProxy), std::forward(toProxy)); } void FenceProxyReleaseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::MemScopeKind scope, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().fromProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), fromProxy); odsState.getOrAddProperties().toProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), toProxy); } FenceProxyReleaseOp FenceProxyReleaseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::MemScopeKind scope, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(scope), std::forward(fromProxy), std::forward(toProxy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyReleaseOp FenceProxyReleaseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::MemScopeKind scope, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { return create(builder, builder.getLoc(), std::forward(scope), std::forward(fromProxy), std::forward(toProxy)); } void FenceProxyReleaseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKind scope, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().fromProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), fromProxy); odsState.getOrAddProperties().toProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), toProxy); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } FenceProxyReleaseOp FenceProxyReleaseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKind scope, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(scope), std::forward(fromProxy), std::forward(toProxy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyReleaseOp FenceProxyReleaseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKind scope, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(scope), std::forward(fromProxy), std::forward(toProxy)); } void FenceProxyReleaseOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } FenceProxyReleaseOp FenceProxyReleaseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyReleaseOp FenceProxyReleaseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void FenceProxyReleaseOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } FenceProxyReleaseOp FenceProxyReleaseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxyReleaseOp FenceProxyReleaseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void FenceProxyReleaseOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.fromProxy) properties.fromProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), ProxyKind::GENERIC); if (!properties.toProxy) properties.toProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), ProxyKind::TENSORMAP); } ::llvm::LogicalResult FenceProxyReleaseOp::verifyInvariantsImpl() { auto tblgen_fromProxy = getProperties().fromProxy; (void)tblgen_fromProxy; auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (!tblgen_scope) return emitOpError("requires attribute 'scope'"); auto tblgen_toProxy = getProperties().toProxy; (void)tblgen_toProxy; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(*this, tblgen_scope, "scope"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps28(*this, tblgen_fromProxy, "fromProxy"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps28(*this, tblgen_toProxy, "toProxy"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult FenceProxyReleaseOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult FenceProxyReleaseOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::MemScopeKindAttr scopeAttr; ::mlir::NVVM::ProxyKindAttr fromProxyAttr; ::mlir::NVVM::ProxyKindAttr toProxyAttr; if (parser.parseCustomAttributeWithFallback(scopeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (scopeAttr) result.getOrAddProperties().scope = scopeAttr; if (::mlir::succeeded(parser.parseOptionalKeyword("from_proxy"))) { if (parser.parseEqual()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(fromProxyAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fromProxyAttr) result.getOrAddProperties().fromProxy = fromProxyAttr; } if (::mlir::succeeded(parser.parseOptionalKeyword("to_proxy"))) { if (parser.parseEqual()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(toProxyAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (toProxyAttr) result.getOrAddProperties().toProxy = toProxyAttr; } { 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 FenceProxyReleaseOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getScopeAttr()); if (getFromProxyAttr() != ::mlir::NVVM::ProxyKindAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ProxyKind::GENERIC)) { _odsPrinter << ' ' << "from_proxy"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getFromProxyAttr()); } if (getToProxyAttr() != ::mlir::NVVM::ProxyKindAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ProxyKind::TENSORMAP)) { _odsPrinter << ' ' << "to_proxy"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getToProxyAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("scope"); elidedAttrs.push_back("fromProxy"); elidedAttrs.push_back("toProxy"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFromProxyAttr(); if(attr && (attr == ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), ProxyKind::GENERIC))) elidedAttrs.push_back("fromProxy"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getToProxyAttr(); if(attr && (attr == ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), ProxyKind::TENSORMAP))) elidedAttrs.push_back("toProxy"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::FenceProxyReleaseOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::FenceProxyReleaseOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::FenceProxySyncRestrictOp definitions //===----------------------------------------------------------------------===// namespace detail { FenceProxySyncRestrictOpGenericAdaptorBase::FenceProxySyncRestrictOpGenericAdaptorBase(FenceProxySyncRestrictOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::MemOrderKind FenceProxySyncRestrictOpGenericAdaptorBase::getOrder() { auto attr = getOrderAttr(); return attr.getValue(); } ::mlir::NVVM::ProxyKindAttr FenceProxySyncRestrictOpGenericAdaptorBase::getFromProxyAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::ProxyKindAttr>(getProperties().fromProxy); return attr; } ::mlir::NVVM::ProxyKind FenceProxySyncRestrictOpGenericAdaptorBase::getFromProxy() { auto attr = getFromProxyAttr(); return attr.getValue(); } ::mlir::NVVM::ProxyKindAttr FenceProxySyncRestrictOpGenericAdaptorBase::getToProxyAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::ProxyKindAttr>(getProperties().toProxy); return attr; } ::mlir::NVVM::ProxyKind FenceProxySyncRestrictOpGenericAdaptorBase::getToProxy() { auto attr = getToProxyAttr(); return attr.getValue(); } } // namespace detail FenceProxySyncRestrictOpAdaptor::FenceProxySyncRestrictOpAdaptor(FenceProxySyncRestrictOp op) : FenceProxySyncRestrictOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult FenceProxySyncRestrictOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fromProxy = getProperties().fromProxy; (void)tblgen_fromProxy; auto tblgen_order = getProperties().order; (void)tblgen_order; if (!tblgen_order) return emitError(loc, "'nvvm.fence.proxy.sync_restrict' op requires attribute 'order'"); auto tblgen_toProxy = getProperties().toProxy; (void)tblgen_toProxy; if (tblgen_order && !(((::llvm::isa<::mlir::NVVM::MemOrderKindAttr>(tblgen_order))) && (((::llvm::cast<::mlir::NVVM::MemOrderKindAttr>(tblgen_order).getValue() == ::mlir::NVVM::MemOrderKind::ACQUIRE)) || ((::llvm::cast<::mlir::NVVM::MemOrderKindAttr>(tblgen_order).getValue() == ::mlir::NVVM::MemOrderKind::RELEASE))))) return emitError(loc, "'nvvm.fence.proxy.sync_restrict' op attribute 'order' failed to satisfy constraint: NVVM Memory Ordering kind whose value is one of {acquire, release}"); if (tblgen_fromProxy && !((::llvm::isa<::mlir::NVVM::ProxyKindAttr>(tblgen_fromProxy)))) return emitError(loc, "'nvvm.fence.proxy.sync_restrict' op attribute 'fromProxy' failed to satisfy constraint: Proxy kind"); if (tblgen_toProxy && !((::llvm::isa<::mlir::NVVM::ProxyKindAttr>(tblgen_toProxy)))) return emitError(loc, "'nvvm.fence.proxy.sync_restrict' op attribute 'toProxy' failed to satisfy constraint: Proxy kind"); return ::mlir::success(); } ::llvm::LogicalResult FenceProxySyncRestrictOp::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.fromProxy; auto attr = dict.get("fromProxy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fromProxy` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.order; auto attr = dict.get("order"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `order` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.toProxy; auto attr = dict.get("toProxy"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `toProxy` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute FenceProxySyncRestrictOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fromProxy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fromProxy", propStorage)); } { const auto &propStorage = prop.order; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("order", propStorage)); } { const auto &propStorage = prop.toProxy; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("toProxy", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code FenceProxySyncRestrictOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fromProxy.getAsOpaquePointer()), llvm::hash_value(prop.order.getAsOpaquePointer()), llvm::hash_value(prop.toProxy.getAsOpaquePointer())); } std::optional FenceProxySyncRestrictOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fromProxy") return prop.fromProxy; if (name == "order") return prop.order; if (name == "toProxy") return prop.toProxy; return std::nullopt; } void FenceProxySyncRestrictOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fromProxy") { prop.fromProxy = ::llvm::dyn_cast_or_null>(value); return; } if (name == "order") { prop.order = ::llvm::dyn_cast_or_null>(value); return; } if (name == "toProxy") { prop.toProxy = ::llvm::dyn_cast_or_null>(value); return; } } void FenceProxySyncRestrictOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fromProxy) attrs.append("fromProxy", prop.fromProxy); if (prop.order) attrs.append("order", prop.order); if (prop.toProxy) attrs.append("toProxy", prop.toProxy); } ::llvm::LogicalResult FenceProxySyncRestrictOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFromProxyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps28(attr, "fromProxy", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getOrderAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps31(attr, "order", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getToProxyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps28(attr, "toProxy", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult FenceProxySyncRestrictOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fromProxy))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.order))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.toProxy))) return ::mlir::failure(); return ::mlir::success(); } void FenceProxySyncRestrictOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fromProxy); writer.writeAttribute(prop.order); writer.writeOptionalAttribute(prop.toProxy); } ::mlir::NVVM::MemOrderKind FenceProxySyncRestrictOp::getOrder() { auto attr = getOrderAttr(); return attr.getValue(); } ::mlir::NVVM::ProxyKind FenceProxySyncRestrictOp::getFromProxy() { auto attr = getFromProxyAttr(); return attr.getValue(); } ::mlir::NVVM::ProxyKind FenceProxySyncRestrictOp::getToProxy() { auto attr = getToProxyAttr(); return attr.getValue(); } void FenceProxySyncRestrictOp::setOrder(::mlir::NVVM::MemOrderKind attrValue) { getProperties().order = ::mlir::NVVM::MemOrderKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FenceProxySyncRestrictOp::setFromProxy(::mlir::NVVM::ProxyKind attrValue) { getProperties().fromProxy = ::mlir::NVVM::ProxyKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FenceProxySyncRestrictOp::setToProxy(::mlir::NVVM::ProxyKind attrValue) { getProperties().toProxy = ::mlir::NVVM::ProxyKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FenceProxySyncRestrictOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::MemOrderKindAttr order, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { odsState.getOrAddProperties().order = order; if (fromProxy) { odsState.getOrAddProperties().fromProxy = fromProxy; } if (toProxy) { odsState.getOrAddProperties().toProxy = toProxy; } } FenceProxySyncRestrictOp FenceProxySyncRestrictOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::MemOrderKindAttr order, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(order), std::forward(fromProxy), std::forward(toProxy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxySyncRestrictOp FenceProxySyncRestrictOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::MemOrderKindAttr order, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { return create(builder, builder.getLoc(), std::forward(order), std::forward(fromProxy), std::forward(toProxy)); } void FenceProxySyncRestrictOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemOrderKindAttr order, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { odsState.getOrAddProperties().order = order; if (fromProxy) { odsState.getOrAddProperties().fromProxy = fromProxy; } if (toProxy) { odsState.getOrAddProperties().toProxy = toProxy; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } FenceProxySyncRestrictOp FenceProxySyncRestrictOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemOrderKindAttr order, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(order), std::forward(fromProxy), std::forward(toProxy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxySyncRestrictOp FenceProxySyncRestrictOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemOrderKindAttr order, ::mlir::NVVM::ProxyKindAttr fromProxy, ::mlir::NVVM::ProxyKindAttr toProxy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(order), std::forward(fromProxy), std::forward(toProxy)); } void FenceProxySyncRestrictOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::MemOrderKind order, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { odsState.getOrAddProperties().order = ::mlir::NVVM::MemOrderKindAttr::get(odsBuilder.getContext(), order); odsState.getOrAddProperties().fromProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), fromProxy); odsState.getOrAddProperties().toProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), toProxy); } FenceProxySyncRestrictOp FenceProxySyncRestrictOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::MemOrderKind order, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(order), std::forward(fromProxy), std::forward(toProxy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxySyncRestrictOp FenceProxySyncRestrictOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::MemOrderKind order, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { return create(builder, builder.getLoc(), std::forward(order), std::forward(fromProxy), std::forward(toProxy)); } void FenceProxySyncRestrictOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemOrderKind order, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { odsState.getOrAddProperties().order = ::mlir::NVVM::MemOrderKindAttr::get(odsBuilder.getContext(), order); odsState.getOrAddProperties().fromProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), fromProxy); odsState.getOrAddProperties().toProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), toProxy); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } FenceProxySyncRestrictOp FenceProxySyncRestrictOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemOrderKind order, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(order), std::forward(fromProxy), std::forward(toProxy)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxySyncRestrictOp FenceProxySyncRestrictOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemOrderKind order, ::mlir::NVVM::ProxyKind fromProxy, ::mlir::NVVM::ProxyKind toProxy) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(order), std::forward(fromProxy), std::forward(toProxy)); } void FenceProxySyncRestrictOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } FenceProxySyncRestrictOp FenceProxySyncRestrictOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxySyncRestrictOp FenceProxySyncRestrictOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void FenceProxySyncRestrictOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } FenceProxySyncRestrictOp FenceProxySyncRestrictOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceProxySyncRestrictOp FenceProxySyncRestrictOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void FenceProxySyncRestrictOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.fromProxy) properties.fromProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), ProxyKind::GENERIC); if (!properties.toProxy) properties.toProxy = ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), ProxyKind::async); } ::llvm::LogicalResult FenceProxySyncRestrictOp::verifyInvariantsImpl() { auto tblgen_fromProxy = getProperties().fromProxy; (void)tblgen_fromProxy; auto tblgen_order = getProperties().order; (void)tblgen_order; if (!tblgen_order) return emitOpError("requires attribute 'order'"); auto tblgen_toProxy = getProperties().toProxy; (void)tblgen_toProxy; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps31(*this, tblgen_order, "order"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps28(*this, tblgen_fromProxy, "fromProxy"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps28(*this, tblgen_toProxy, "toProxy"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult FenceProxySyncRestrictOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult FenceProxySyncRestrictOp::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 FenceProxySyncRestrictOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFromProxyAttr(); if(attr && (attr == ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), ProxyKind::GENERIC))) elidedAttrs.push_back("fromProxy"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getToProxyAttr(); if(attr && (attr == ::mlir::NVVM::ProxyKindAttr::get(odsBuilder.getContext(), ProxyKind::async))) elidedAttrs.push_back("toProxy"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::FenceProxySyncRestrictOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::FenceProxySyncRestrictOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::FenceScClusterOp definitions //===----------------------------------------------------------------------===// namespace detail { FenceScClusterOpGenericAdaptorBase::FenceScClusterOpGenericAdaptorBase(FenceScClusterOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail FenceScClusterOpAdaptor::FenceScClusterOpAdaptor(FenceScClusterOp op) : FenceScClusterOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult FenceScClusterOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult FenceScClusterOp::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 FenceScClusterOp::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 FenceScClusterOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional FenceScClusterOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void FenceScClusterOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void FenceScClusterOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult FenceScClusterOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void FenceScClusterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { } FenceScClusterOp FenceScClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceScClusterOp FenceScClusterOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void FenceScClusterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } FenceScClusterOp FenceScClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceScClusterOp FenceScClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void FenceScClusterOp::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); } FenceScClusterOp FenceScClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceScClusterOp FenceScClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void FenceScClusterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } FenceScClusterOp FenceScClusterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceScClusterOp FenceScClusterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult FenceScClusterOp::verifyInvariantsImpl() { return ::mlir::success(); } ::llvm::LogicalResult FenceScClusterOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult FenceScClusterOp::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 FenceScClusterOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::FenceScClusterOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::FenceSyncRestrictOp definitions //===----------------------------------------------------------------------===// namespace detail { FenceSyncRestrictOpGenericAdaptorBase::FenceSyncRestrictOpGenericAdaptorBase(FenceSyncRestrictOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::MemOrderKind FenceSyncRestrictOpGenericAdaptorBase::getOrder() { auto attr = getOrderAttr(); return attr.getValue(); } } // namespace detail FenceSyncRestrictOpAdaptor::FenceSyncRestrictOpAdaptor(FenceSyncRestrictOp op) : FenceSyncRestrictOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult FenceSyncRestrictOpAdaptor::verify(::mlir::Location loc) { auto tblgen_order = getProperties().order; (void)tblgen_order; if (!tblgen_order) return emitError(loc, "'nvvm.fence.sync_restrict' op requires attribute 'order'"); if (tblgen_order && !(((::llvm::isa<::mlir::NVVM::MemOrderKindAttr>(tblgen_order))) && (((::llvm::cast<::mlir::NVVM::MemOrderKindAttr>(tblgen_order).getValue() == ::mlir::NVVM::MemOrderKind::ACQUIRE)) || ((::llvm::cast<::mlir::NVVM::MemOrderKindAttr>(tblgen_order).getValue() == ::mlir::NVVM::MemOrderKind::RELEASE))))) return emitError(loc, "'nvvm.fence.sync_restrict' op attribute 'order' failed to satisfy constraint: NVVM Memory Ordering kind whose value is one of {acquire, release}"); return ::mlir::success(); } ::llvm::LogicalResult FenceSyncRestrictOp::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.order; auto attr = dict.get("order"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `order` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute FenceSyncRestrictOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.order; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("order", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code FenceSyncRestrictOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.order.getAsOpaquePointer())); } std::optional FenceSyncRestrictOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "order") return prop.order; return std::nullopt; } void FenceSyncRestrictOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "order") { prop.order = ::llvm::dyn_cast_or_null>(value); return; } } void FenceSyncRestrictOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.order) attrs.append("order", prop.order); } ::llvm::LogicalResult FenceSyncRestrictOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getOrderAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps31(attr, "order", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult FenceSyncRestrictOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.order))) return ::mlir::failure(); return ::mlir::success(); } void FenceSyncRestrictOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.order); } ::mlir::NVVM::MemOrderKind FenceSyncRestrictOp::getOrder() { auto attr = getOrderAttr(); return attr.getValue(); } void FenceSyncRestrictOp::setOrder(::mlir::NVVM::MemOrderKind attrValue) { getProperties().order = ::mlir::NVVM::MemOrderKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FenceSyncRestrictOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::MemOrderKindAttr order) { odsState.getOrAddProperties().order = order; } FenceSyncRestrictOp FenceSyncRestrictOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::MemOrderKindAttr order) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(order)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceSyncRestrictOp FenceSyncRestrictOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::MemOrderKindAttr order) { return create(builder, builder.getLoc(), std::forward(order)); } void FenceSyncRestrictOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemOrderKindAttr order) { odsState.getOrAddProperties().order = order; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } FenceSyncRestrictOp FenceSyncRestrictOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemOrderKindAttr order) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(order)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceSyncRestrictOp FenceSyncRestrictOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemOrderKindAttr order) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(order)); } void FenceSyncRestrictOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::MemOrderKind order) { odsState.getOrAddProperties().order = ::mlir::NVVM::MemOrderKindAttr::get(odsBuilder.getContext(), order); } FenceSyncRestrictOp FenceSyncRestrictOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::MemOrderKind order) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(order)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceSyncRestrictOp FenceSyncRestrictOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::MemOrderKind order) { return create(builder, builder.getLoc(), std::forward(order)); } void FenceSyncRestrictOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemOrderKind order) { odsState.getOrAddProperties().order = ::mlir::NVVM::MemOrderKindAttr::get(odsBuilder.getContext(), order); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } FenceSyncRestrictOp FenceSyncRestrictOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemOrderKind order) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(order)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceSyncRestrictOp FenceSyncRestrictOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemOrderKind order) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(order)); } void FenceSyncRestrictOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } FenceSyncRestrictOp FenceSyncRestrictOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceSyncRestrictOp FenceSyncRestrictOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void FenceSyncRestrictOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } FenceSyncRestrictOp FenceSyncRestrictOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FenceSyncRestrictOp FenceSyncRestrictOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult FenceSyncRestrictOp::verifyInvariantsImpl() { auto tblgen_order = getProperties().order; (void)tblgen_order; if (!tblgen_order) return emitOpError("requires attribute 'order'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps31(*this, tblgen_order, "order"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult FenceSyncRestrictOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult FenceSyncRestrictOp::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 FenceSyncRestrictOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::FenceSyncRestrictOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::FenceSyncRestrictOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::FmaOp definitions //===----------------------------------------------------------------------===// namespace detail { FmaOpGenericAdaptorBase::FmaOpGenericAdaptorBase(FmaOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::FPRoundingMode FmaOpGenericAdaptorBase::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::NVVM::SaturationModeAttr FmaOpGenericAdaptorBase::getSatAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::SaturationModeAttr>(getProperties().sat); return attr; } ::mlir::NVVM::SaturationMode FmaOpGenericAdaptorBase::getSat() { auto attr = getSatAttr(); return attr.getValue(); } ::mlir::BoolAttr FmaOpGenericAdaptorBase::getFtzAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().ftz); return attr; } bool FmaOpGenericAdaptorBase::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } ::mlir::BoolAttr FmaOpGenericAdaptorBase::getReluAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relu); return attr; } bool FmaOpGenericAdaptorBase::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } ::mlir::BoolAttr FmaOpGenericAdaptorBase::getOobAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().oob); return attr; } bool FmaOpGenericAdaptorBase::getOob() { auto attr = getOobAttr(); return attr.getValue(); } } // namespace detail FmaOpAdaptor::FmaOpAdaptor(FmaOp op) : FmaOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult FmaOpAdaptor::verify(::mlir::Location loc) { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; auto tblgen_oob = getProperties().oob; (void)tblgen_oob; auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; if (!tblgen_rnd) return emitError(loc, "'nvvm.fma' op requires attribute 'rnd'"); auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (tblgen_rnd && !(((::llvm::isa<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd))) && (((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::NONE)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RM)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RN)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RP)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RZ))))) return emitError(loc, "'nvvm.fma' op attribute 'rnd' failed to satisfy constraint: NVVM FPRoundingMode kind whose value is one of {none, rm, rn, rp, rz}"); if (tblgen_sat && !(((::llvm::isa<::mlir::NVVM::SaturationModeAttr>(tblgen_sat))) && (((::llvm::cast<::mlir::NVVM::SaturationModeAttr>(tblgen_sat).getValue() == ::mlir::NVVM::SaturationMode::NONE)) || ((::llvm::cast<::mlir::NVVM::SaturationModeAttr>(tblgen_sat).getValue() == ::mlir::NVVM::SaturationMode::SAT))))) return emitError(loc, "'nvvm.fma' op attribute 'sat' failed to satisfy constraint: Describes the saturation mode whose value is one of {none, sat}"); if (tblgen_ftz && !((::llvm::isa<::mlir::BoolAttr>(tblgen_ftz)))) return emitError(loc, "'nvvm.fma' op attribute 'ftz' failed to satisfy constraint: bool attribute"); if (tblgen_relu && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relu)))) return emitError(loc, "'nvvm.fma' op attribute 'relu' failed to satisfy constraint: bool attribute"); if (tblgen_oob && !((::llvm::isa<::mlir::BoolAttr>(tblgen_oob)))) return emitError(loc, "'nvvm.fma' op attribute 'oob' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult FmaOp::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.ftz; auto attr = dict.get("ftz"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ftz` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.oob; auto attr = dict.get("oob"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `oob` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.relu; auto attr = dict.get("relu"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relu` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.rnd; auto attr = dict.get("rnd"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `rnd` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sat; auto attr = dict.get("sat"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sat` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute FmaOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.ftz; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ftz", propStorage)); } { const auto &propStorage = prop.oob; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("oob", propStorage)); } { const auto &propStorage = prop.relu; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relu", propStorage)); } { const auto &propStorage = prop.rnd; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("rnd", propStorage)); } { const auto &propStorage = prop.sat; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sat", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code FmaOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.ftz.getAsOpaquePointer()), llvm::hash_value(prop.oob.getAsOpaquePointer()), llvm::hash_value(prop.relu.getAsOpaquePointer()), llvm::hash_value(prop.rnd.getAsOpaquePointer()), llvm::hash_value(prop.sat.getAsOpaquePointer())); } std::optional FmaOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "ftz") return prop.ftz; if (name == "oob") return prop.oob; if (name == "relu") return prop.relu; if (name == "rnd") return prop.rnd; if (name == "sat") return prop.sat; return std::nullopt; } void FmaOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "ftz") { prop.ftz = ::llvm::dyn_cast_or_null>(value); return; } if (name == "oob") { prop.oob = ::llvm::dyn_cast_or_null>(value); return; } if (name == "relu") { prop.relu = ::llvm::dyn_cast_or_null>(value); return; } if (name == "rnd") { prop.rnd = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sat") { prop.sat = ::llvm::dyn_cast_or_null>(value); return; } } void FmaOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.ftz) attrs.append("ftz", prop.ftz); if (prop.oob) attrs.append("oob", prop.oob); if (prop.relu) attrs.append("relu", prop.relu); if (prop.rnd) attrs.append("rnd", prop.rnd); if (prop.sat) attrs.append("sat", prop.sat); } ::llvm::LogicalResult FmaOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFtzAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "ftz", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getOobAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "oob", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReluAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relu", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRndAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps1(attr, "rnd", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSatAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps2(attr, "sat", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult FmaOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.ftz))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.oob))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.relu))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.rnd))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.sat))) return ::mlir::failure(); return ::mlir::success(); } void FmaOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.ftz); writer.writeOptionalAttribute(prop.oob); writer.writeOptionalAttribute(prop.relu); writer.writeAttribute(prop.rnd); writer.writeOptionalAttribute(prop.sat); } ::mlir::NVVM::FPRoundingMode FmaOp::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::NVVM::SaturationMode FmaOp::getSat() { auto attr = getSatAttr(); return attr.getValue(); } bool FmaOp::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } bool FmaOp::getRelu() { auto attr = getReluAttr(); return attr.getValue(); } bool FmaOp::getOob() { auto attr = getOobAttr(); return attr.getValue(); } void FmaOp::setRnd(::mlir::NVVM::FPRoundingMode attrValue) { getProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FmaOp::setSat(::mlir::NVVM::SaturationMode attrValue) { getProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FmaOp::setFtz(bool attrValue) { getProperties().ftz = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void FmaOp::setRelu(bool attrValue) { getProperties().relu = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void FmaOp::setOob(bool attrValue) { getProperties().oob = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void FmaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz, ::mlir::BoolAttr relu, ::mlir::BoolAttr oob) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().rnd = rnd; if (sat) { odsState.getOrAddProperties().sat = sat; } if (ftz) { odsState.getOrAddProperties().ftz = ftz; } if (relu) { odsState.getOrAddProperties().relu = relu; } if (oob) { odsState.getOrAddProperties().oob = oob; } odsState.addTypes(res); } FmaOp FmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz, ::mlir::BoolAttr relu, ::mlir::BoolAttr oob) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(a), std::forward(b), std::forward(c), std::forward(rnd), std::forward(sat), std::forward(ftz), std::forward(relu), std::forward(oob)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FmaOp FmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz, ::mlir::BoolAttr relu, ::mlir::BoolAttr oob) { return create(builder, builder.getLoc(), std::forward(res), std::forward(a), std::forward(b), std::forward(c), std::forward(rnd), std::forward(sat), std::forward(ftz), std::forward(relu), std::forward(oob)); } void FmaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz, ::mlir::BoolAttr relu, ::mlir::BoolAttr oob) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().rnd = rnd; if (sat) { odsState.getOrAddProperties().sat = sat; } if (ftz) { odsState.getOrAddProperties().ftz = ftz; } if (relu) { odsState.getOrAddProperties().relu = relu; } if (oob) { odsState.getOrAddProperties().oob = oob; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(FmaOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } FmaOp FmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz, ::mlir::BoolAttr relu, ::mlir::BoolAttr oob) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(a), std::forward(b), std::forward(c), std::forward(rnd), std::forward(sat), std::forward(ftz), std::forward(relu), std::forward(oob)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FmaOp FmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz, ::mlir::BoolAttr relu, ::mlir::BoolAttr oob) { return create(builder, builder.getLoc(), std::forward(a), std::forward(b), std::forward(c), std::forward(rnd), std::forward(sat), std::forward(ftz), std::forward(relu), std::forward(oob)); } void FmaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz, ::mlir::BoolAttr relu, ::mlir::BoolAttr oob) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().rnd = rnd; if (sat) { odsState.getOrAddProperties().sat = sat; } if (ftz) { odsState.getOrAddProperties().ftz = ftz; } if (relu) { odsState.getOrAddProperties().relu = relu; } if (oob) { odsState.getOrAddProperties().oob = oob; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } FmaOp FmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz, ::mlir::BoolAttr relu, ::mlir::BoolAttr oob) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(c), std::forward(rnd), std::forward(sat), std::forward(ftz), std::forward(relu), std::forward(oob)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FmaOp FmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz, ::mlir::BoolAttr relu, ::mlir::BoolAttr oob) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(c), std::forward(rnd), std::forward(sat), std::forward(ftz), std::forward(relu), std::forward(oob)); } void FmaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz, bool relu, bool oob) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().oob = odsBuilder.getBoolAttr(oob); odsState.addTypes(res); } FmaOp FmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz, bool relu, bool oob) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(a), std::forward(b), std::forward(c), std::forward(rnd), std::forward(sat), std::forward(ftz), std::forward(relu), std::forward(oob)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FmaOp FmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz, bool relu, bool oob) { return create(builder, builder.getLoc(), std::forward(res), std::forward(a), std::forward(b), std::forward(c), std::forward(rnd), std::forward(sat), std::forward(ftz), std::forward(relu), std::forward(oob)); } void FmaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz, bool relu, bool oob) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().oob = odsBuilder.getBoolAttr(oob); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(FmaOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } FmaOp FmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz, bool relu, bool oob) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(a), std::forward(b), std::forward(c), std::forward(rnd), std::forward(sat), std::forward(ftz), std::forward(relu), std::forward(oob)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FmaOp FmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz, bool relu, bool oob) { return create(builder, builder.getLoc(), std::forward(a), std::forward(b), std::forward(c), std::forward(rnd), std::forward(sat), std::forward(ftz), std::forward(relu), std::forward(oob)); } void FmaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz, bool relu, bool oob) { odsState.addOperands(a); odsState.addOperands(b); odsState.addOperands(c); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); odsState.getOrAddProperties().relu = odsBuilder.getBoolAttr(relu); odsState.getOrAddProperties().oob = odsBuilder.getBoolAttr(oob); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } FmaOp FmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz, bool relu, bool oob) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(c), std::forward(rnd), std::forward(sat), std::forward(ftz), std::forward(relu), std::forward(oob)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FmaOp FmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz, bool relu, bool oob) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(b), std::forward(c), std::forward(rnd), std::forward(sat), std::forward(ftz), std::forward(relu), std::forward(oob)); } void FmaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } FmaOp FmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FmaOp FmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void FmaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(FmaOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } FmaOp FmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FmaOp FmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void FmaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } FmaOp FmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FmaOp FmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void FmaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(FmaOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } FmaOp FmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FmaOp FmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void FmaOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.sat) properties.sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE); if (!properties.ftz) properties.ftz = odsBuilder.getBoolAttr(false); if (!properties.relu) properties.relu = odsBuilder.getBoolAttr(false); if (!properties.oob) properties.oob = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult FmaOp::verifyInvariantsImpl() { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; auto tblgen_oob = getProperties().oob; (void)tblgen_oob; auto tblgen_relu = getProperties().relu; (void)tblgen_relu; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; if (!tblgen_rnd) return emitOpError("requires attribute 'rnd'"); auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps1(*this, tblgen_rnd, "rnd"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps2(*this, tblgen_sat, "sat"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_ftz, "ftz"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relu, "relu"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_oob, "oob"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps1(*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_NVVMOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult FmaOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult FmaOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); if (operands.size() <= 0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[0].getType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult FmaOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand aRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(&aRawOperand, 1); ::llvm::SMLoc aOperandsLoc; (void)aOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand bRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> bOperands(&bRawOperand, 1); ::llvm::SMLoc bOperandsLoc; (void)bOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand cRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> cOperands(&cRawOperand, 1); ::llvm::SMLoc cOperandsLoc; (void)cOperandsLoc; ::mlir::Type aRawType{}; ::llvm::ArrayRef<::mlir::Type> aTypes(&aRawType, 1); aOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(aRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); bOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(bRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); cOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(cRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); aRawType = type; } result.addTypes(aTypes[0]); if (parser.resolveOperands(aOperands, aTypes, aOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(bOperands, aTypes[0], bOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(cOperands, aTypes[0], cOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void FmaOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getA(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getB(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getC(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getSatAttr(); if(attr && (attr == ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE))) elidedAttrs.push_back("sat"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFtzAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("ftz"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getReluAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relu"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getOobAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("oob"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getA().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void FmaOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::FmaOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::FmaOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::GlobalTimerLoOp definitions //===----------------------------------------------------------------------===// namespace detail { GlobalTimerLoOpGenericAdaptorBase::GlobalTimerLoOpGenericAdaptorBase(GlobalTimerLoOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail GlobalTimerLoOpAdaptor::GlobalTimerLoOpAdaptor(GlobalTimerLoOp op) : GlobalTimerLoOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GlobalTimerLoOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult GlobalTimerLoOp::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 GlobalTimerLoOp::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 GlobalTimerLoOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional GlobalTimerLoOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void GlobalTimerLoOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void GlobalTimerLoOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult GlobalTimerLoOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void GlobalTimerLoOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } GlobalTimerLoOp GlobalTimerLoOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalTimerLoOp GlobalTimerLoOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void GlobalTimerLoOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GlobalTimerLoOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } GlobalTimerLoOp GlobalTimerLoOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalTimerLoOp GlobalTimerLoOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void GlobalTimerLoOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } GlobalTimerLoOp GlobalTimerLoOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalTimerLoOp GlobalTimerLoOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void GlobalTimerLoOp::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); } GlobalTimerLoOp GlobalTimerLoOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalTimerLoOp GlobalTimerLoOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void GlobalTimerLoOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GlobalTimerLoOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } GlobalTimerLoOp GlobalTimerLoOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalTimerLoOp GlobalTimerLoOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void GlobalTimerLoOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } GlobalTimerLoOp GlobalTimerLoOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalTimerLoOp GlobalTimerLoOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void GlobalTimerLoOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GlobalTimerLoOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } GlobalTimerLoOp GlobalTimerLoOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalTimerLoOp GlobalTimerLoOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult GlobalTimerLoOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult GlobalTimerLoOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult GlobalTimerLoOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult GlobalTimerLoOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void GlobalTimerLoOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::GlobalTimerLoOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::GlobalTimerOp definitions //===----------------------------------------------------------------------===// namespace detail { GlobalTimerOpGenericAdaptorBase::GlobalTimerOpGenericAdaptorBase(GlobalTimerOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail GlobalTimerOpAdaptor::GlobalTimerOpAdaptor(GlobalTimerOp op) : GlobalTimerOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GlobalTimerOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult GlobalTimerOp::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 GlobalTimerOp::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 GlobalTimerOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional GlobalTimerOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void GlobalTimerOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void GlobalTimerOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult GlobalTimerOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void GlobalTimerOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } GlobalTimerOp GlobalTimerOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalTimerOp GlobalTimerOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void GlobalTimerOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GlobalTimerOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } GlobalTimerOp GlobalTimerOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalTimerOp GlobalTimerOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void GlobalTimerOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } GlobalTimerOp GlobalTimerOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalTimerOp GlobalTimerOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void GlobalTimerOp::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); } GlobalTimerOp GlobalTimerOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalTimerOp GlobalTimerOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void GlobalTimerOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GlobalTimerOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } GlobalTimerOp GlobalTimerOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalTimerOp GlobalTimerOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void GlobalTimerOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } GlobalTimerOp GlobalTimerOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalTimerOp GlobalTimerOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void GlobalTimerOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GlobalTimerOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } GlobalTimerOp GlobalTimerOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalTimerOp GlobalTimerOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult GlobalTimerOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult GlobalTimerOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult GlobalTimerOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(64); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult GlobalTimerOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void GlobalTimerOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::GlobalTimerOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::GridDimXOp definitions //===----------------------------------------------------------------------===// namespace detail { GridDimXOpGenericAdaptorBase::GridDimXOpGenericAdaptorBase(GridDimXOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> GridDimXOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail GridDimXOpAdaptor::GridDimXOpAdaptor(GridDimXOp op) : GridDimXOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GridDimXOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.nctaid.x' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult GridDimXOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute GridDimXOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code GridDimXOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional GridDimXOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void GridDimXOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void GridDimXOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult GridDimXOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult GridDimXOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void GridDimXOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> GridDimXOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void GridDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } GridDimXOp GridDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimXOp GridDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void GridDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } GridDimXOp GridDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimXOp GridDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void GridDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GridDimXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } GridDimXOp GridDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimXOp GridDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void GridDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } GridDimXOp GridDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimXOp GridDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void GridDimXOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } GridDimXOp GridDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimXOp GridDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void GridDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GridDimXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } GridDimXOp GridDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimXOp GridDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void GridDimXOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } GridDimXOp GridDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimXOp GridDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void GridDimXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GridDimXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } GridDimXOp GridDimXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimXOp GridDimXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult GridDimXOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult GridDimXOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult GridDimXOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult GridDimXOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void GridDimXOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void GridDimXOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void GridDimXOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult GridDimXOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::GridDimXOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::GridDimXOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::GridDimYOp definitions //===----------------------------------------------------------------------===// namespace detail { GridDimYOpGenericAdaptorBase::GridDimYOpGenericAdaptorBase(GridDimYOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> GridDimYOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail GridDimYOpAdaptor::GridDimYOpAdaptor(GridDimYOp op) : GridDimYOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GridDimYOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.nctaid.y' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult GridDimYOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute GridDimYOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code GridDimYOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional GridDimYOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void GridDimYOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void GridDimYOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult GridDimYOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult GridDimYOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void GridDimYOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> GridDimYOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void GridDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } GridDimYOp GridDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimYOp GridDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void GridDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } GridDimYOp GridDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimYOp GridDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void GridDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GridDimYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } GridDimYOp GridDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimYOp GridDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void GridDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } GridDimYOp GridDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimYOp GridDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void GridDimYOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } GridDimYOp GridDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimYOp GridDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void GridDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GridDimYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } GridDimYOp GridDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimYOp GridDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void GridDimYOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } GridDimYOp GridDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimYOp GridDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void GridDimYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GridDimYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } GridDimYOp GridDimYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimYOp GridDimYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult GridDimYOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult GridDimYOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult GridDimYOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult GridDimYOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void GridDimYOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void GridDimYOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void GridDimYOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult GridDimYOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::GridDimYOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::GridDimYOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::GridDimZOp definitions //===----------------------------------------------------------------------===// namespace detail { GridDimZOpGenericAdaptorBase::GridDimZOpGenericAdaptorBase(GridDimZOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> GridDimZOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail GridDimZOpAdaptor::GridDimZOpAdaptor(GridDimZOp op) : GridDimZOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GridDimZOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.nctaid.z' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult GridDimZOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute GridDimZOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code GridDimZOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional GridDimZOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void GridDimZOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void GridDimZOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult GridDimZOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult GridDimZOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void GridDimZOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> GridDimZOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void GridDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } GridDimZOp GridDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimZOp GridDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void GridDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } GridDimZOp GridDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimZOp GridDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void GridDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GridDimZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } GridDimZOp GridDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimZOp GridDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void GridDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } GridDimZOp GridDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimZOp GridDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void GridDimZOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } GridDimZOp GridDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimZOp GridDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void GridDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GridDimZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } GridDimZOp GridDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimZOp GridDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void GridDimZOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } GridDimZOp GridDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimZOp GridDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void GridDimZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GridDimZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } GridDimZOp GridDimZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridDimZOp GridDimZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult GridDimZOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult GridDimZOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult GridDimZOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult GridDimZOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void GridDimZOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void GridDimZOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void GridDimZOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult GridDimZOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::GridDimZOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::GridDimZOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::GridIdOp definitions //===----------------------------------------------------------------------===// namespace detail { GridIdOpGenericAdaptorBase::GridIdOpGenericAdaptorBase(GridIdOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> GridIdOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail GridIdOpAdaptor::GridIdOpAdaptor(GridIdOp op) : GridIdOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GridIdOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.gridid' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult GridIdOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute GridIdOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code GridIdOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional GridIdOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void GridIdOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void GridIdOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult GridIdOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult GridIdOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void GridIdOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> GridIdOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void GridIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } GridIdOp GridIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridIdOp GridIdOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void GridIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } GridIdOp GridIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridIdOp GridIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void GridIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GridIdOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } GridIdOp GridIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridIdOp GridIdOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void GridIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } GridIdOp GridIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridIdOp GridIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void GridIdOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } GridIdOp GridIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridIdOp GridIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void GridIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GridIdOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } GridIdOp GridIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridIdOp GridIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void GridIdOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } GridIdOp GridIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridIdOp GridIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void GridIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GridIdOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } GridIdOp GridIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GridIdOp GridIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult GridIdOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult GridIdOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult GridIdOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult GridIdOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void GridIdOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void GridIdOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void GridIdOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult GridIdOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::GridIdOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::GridIdOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::GriddepcontrolOp definitions //===----------------------------------------------------------------------===// namespace detail { GriddepcontrolOpGenericAdaptorBase::GriddepcontrolOpGenericAdaptorBase(GriddepcontrolOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::GridDepActionKind GriddepcontrolOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } } // namespace detail GriddepcontrolOpAdaptor::GriddepcontrolOpAdaptor(GriddepcontrolOp op) : GriddepcontrolOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GriddepcontrolOpAdaptor::verify(::mlir::Location loc) { auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'nvvm.griddepcontrol' op requires attribute 'kind'"); if (tblgen_kind && !((::llvm::isa<::mlir::NVVM::GridDepActionKindAttr>(tblgen_kind)))) return emitError(loc, "'nvvm.griddepcontrol' op attribute 'kind' failed to satisfy constraint: Action kind for grid dependency control"); return ::mlir::success(); } ::llvm::LogicalResult GriddepcontrolOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute GriddepcontrolOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code GriddepcontrolOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.kind.getAsOpaquePointer())); } std::optional GriddepcontrolOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "kind") return prop.kind; return std::nullopt; } void GriddepcontrolOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } } void GriddepcontrolOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.kind) attrs.append("kind", prop.kind); } ::llvm::LogicalResult GriddepcontrolOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps32(attr, "kind", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult GriddepcontrolOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.kind))) return ::mlir::failure(); return ::mlir::success(); } void GriddepcontrolOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.kind); } ::mlir::NVVM::GridDepActionKind GriddepcontrolOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } void GriddepcontrolOp::setKind(::mlir::NVVM::GridDepActionKind attrValue) { getProperties().kind = ::mlir::NVVM::GridDepActionKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void GriddepcontrolOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::GridDepActionKindAttr kind) { odsState.getOrAddProperties().kind = kind; } GriddepcontrolOp GriddepcontrolOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::GridDepActionKindAttr kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GriddepcontrolOp GriddepcontrolOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::GridDepActionKindAttr kind) { return create(builder, builder.getLoc(), std::forward(kind)); } void GriddepcontrolOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::GridDepActionKindAttr kind) { odsState.getOrAddProperties().kind = kind; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } GriddepcontrolOp GriddepcontrolOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::GridDepActionKindAttr kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GriddepcontrolOp GriddepcontrolOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::GridDepActionKindAttr kind) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind)); } void GriddepcontrolOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::GridDepActionKind kind) { odsState.getOrAddProperties().kind = ::mlir::NVVM::GridDepActionKindAttr::get(odsBuilder.getContext(), kind); } GriddepcontrolOp GriddepcontrolOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::GridDepActionKind kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GriddepcontrolOp GriddepcontrolOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::GridDepActionKind kind) { return create(builder, builder.getLoc(), std::forward(kind)); } void GriddepcontrolOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::GridDepActionKind kind) { odsState.getOrAddProperties().kind = ::mlir::NVVM::GridDepActionKindAttr::get(odsBuilder.getContext(), kind); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } GriddepcontrolOp GriddepcontrolOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::GridDepActionKind kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GriddepcontrolOp GriddepcontrolOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::GridDepActionKind kind) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind)); } void GriddepcontrolOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } GriddepcontrolOp GriddepcontrolOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GriddepcontrolOp GriddepcontrolOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void GriddepcontrolOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } GriddepcontrolOp GriddepcontrolOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GriddepcontrolOp GriddepcontrolOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult GriddepcontrolOp::verifyInvariantsImpl() { auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps32(*this, tblgen_kind, "kind"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult GriddepcontrolOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult GriddepcontrolOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::GridDepActionKindAttr kindAttr; if (parser.parseCustomAttributeWithFallback(kindAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (kindAttr) result.getOrAddProperties().kind = kindAttr; { 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 GriddepcontrolOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getKindAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("kind"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::GriddepcontrolOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::GriddepcontrolOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::InlinePtxOp definitions //===----------------------------------------------------------------------===// namespace detail { InlinePtxOpGenericAdaptorBase::InlinePtxOpGenericAdaptorBase(InlinePtxOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair InlinePtxOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::llvm::StringRef InlinePtxOpGenericAdaptorBase::getPtxCode() { auto attr = getPtxCodeAttr(); return attr.getValue(); } } // namespace detail InlinePtxOpAdaptor::InlinePtxOpAdaptor(InlinePtxOp op) : InlinePtxOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult InlinePtxOpAdaptor::verify(::mlir::Location loc) { auto tblgen_ptxCode = getProperties().ptxCode; (void)tblgen_ptxCode; if (!tblgen_ptxCode) return emitError(loc, "'nvvm.inline_ptx' op requires attribute 'ptxCode'"); if (tblgen_ptxCode && !((::llvm::isa<::mlir::StringAttr>(tblgen_ptxCode)))) return emitError(loc, "'nvvm.inline_ptx' op attribute 'ptxCode' failed to satisfy constraint: string attribute"); return ::mlir::success(); } std::pair InlinePtxOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange InlinePtxOp::getReadOnlyArgsMutable() { 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 InlinePtxOp::getReadWriteArgsMutable() { 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 InlinePtxOp::getPredicateMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } std::pair InlinePtxOp::getODSResultIndexAndLength(unsigned index) { bool isVariadic[] = {true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumResults() - 0) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::llvm::LogicalResult InlinePtxOp::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.ptxCode; auto attr = dict.get("ptxCode"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ptxCode` 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 InlinePtxOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.ptxCode; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ptxCode", 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 InlinePtxOp::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.ptxCode.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional InlinePtxOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "ptxCode") return prop.ptxCode; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void InlinePtxOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "ptxCode") { prop.ptxCode = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void InlinePtxOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.ptxCode) attrs.append("ptxCode", prop.ptxCode); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult InlinePtxOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getPtxCodeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps33(attr, "ptxCode", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult InlinePtxOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readAttribute(prop.ptxCode))) 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 InlinePtxOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeAttribute(prop.ptxCode); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::llvm::StringRef InlinePtxOp::getPtxCode() { auto attr = getPtxCodeAttr(); return attr.getValue(); } void InlinePtxOp::setPtxCode(::llvm::StringRef attrValue) { getProperties().ptxCode = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue); } void InlinePtxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange writeOnlyArgs, ::mlir::ValueRange readOnlyArgs, ::mlir::ValueRange readWriteArgs, ::mlir::StringAttr ptxCode, /*optional*/::mlir::Value predicate) { odsState.addOperands(readOnlyArgs); odsState.addOperands(readWriteArgs); if (predicate) odsState.addOperands(predicate); ::llvm::copy(::llvm::ArrayRef({static_cast(readOnlyArgs.size()), static_cast(readWriteArgs.size()), (predicate ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().ptxCode = ptxCode; odsState.addTypes(writeOnlyArgs); } InlinePtxOp InlinePtxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange writeOnlyArgs, ::mlir::ValueRange readOnlyArgs, ::mlir::ValueRange readWriteArgs, ::mlir::StringAttr ptxCode, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(writeOnlyArgs), std::forward(readOnlyArgs), std::forward(readWriteArgs), std::forward(ptxCode), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } InlinePtxOp InlinePtxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange writeOnlyArgs, ::mlir::ValueRange readOnlyArgs, ::mlir::ValueRange readWriteArgs, ::mlir::StringAttr ptxCode, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(writeOnlyArgs), std::forward(readOnlyArgs), std::forward(readWriteArgs), std::forward(ptxCode), std::forward(predicate)); } void InlinePtxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange writeOnlyArgs, ::mlir::ValueRange readOnlyArgs, ::mlir::ValueRange readWriteArgs, ::llvm::StringRef ptxCode, /*optional*/::mlir::Value predicate) { odsState.addOperands(readOnlyArgs); odsState.addOperands(readWriteArgs); if (predicate) odsState.addOperands(predicate); ::llvm::copy(::llvm::ArrayRef({static_cast(readOnlyArgs.size()), static_cast(readWriteArgs.size()), (predicate ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().ptxCode = odsBuilder.getStringAttr(ptxCode); odsState.addTypes(writeOnlyArgs); } InlinePtxOp InlinePtxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange writeOnlyArgs, ::mlir::ValueRange readOnlyArgs, ::mlir::ValueRange readWriteArgs, ::llvm::StringRef ptxCode, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(writeOnlyArgs), std::forward(readOnlyArgs), std::forward(readWriteArgs), std::forward(ptxCode), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } InlinePtxOp InlinePtxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange writeOnlyArgs, ::mlir::ValueRange readOnlyArgs, ::mlir::ValueRange readWriteArgs, ::llvm::StringRef ptxCode, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(writeOnlyArgs), std::forward(readOnlyArgs), std::forward(readWriteArgs), std::forward(ptxCode), std::forward(predicate)); } void InlinePtxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } InlinePtxOp InlinePtxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } InlinePtxOp InlinePtxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void InlinePtxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); odsState.addTypes(resultTypes); } InlinePtxOp InlinePtxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } InlinePtxOp InlinePtxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult InlinePtxOp::verifyInvariantsImpl() { auto tblgen_ptxCode = getProperties().ptxCode; (void)tblgen_ptxCode; if (!tblgen_ptxCode) return emitOpError("requires attribute 'ptxCode'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps33(*this, tblgen_ptxCode, "ptxCode"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps27(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps27(*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_NVVMOps23(*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_NVVMOps27(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult InlinePtxOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult InlinePtxOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::StringAttr ptxCodeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> readOnlyArgsOperands; ::llvm::SMLoc readOnlyArgsOperandsLoc; (void)readOnlyArgsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> readOnlyArgsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> readWriteArgsOperands; ::llvm::SMLoc readWriteArgsOperandsLoc; (void)readWriteArgsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> readWriteArgsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> predicateOperands; ::llvm::SMLoc predicateOperandsLoc; (void)predicateOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> writeOnlyArgsTypes; if (parser.parseCustomAttributeWithFallback(ptxCodeAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (ptxCodeAttr) result.getOrAddProperties().ptxCode = ptxCodeAttr; if (::mlir::succeeded(parser.parseOptionalKeyword("ro"))) { if (parser.parseLParen()) return ::mlir::failure(); readOnlyArgsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(readOnlyArgsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(readOnlyArgsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } if (::mlir::succeeded(parser.parseOptionalKeyword("rw"))) { if (parser.parseLParen()) return ::mlir::failure(); readWriteArgsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(readWriteArgsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(readWriteArgsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } if (::mlir::succeeded(parser.parseOptionalComma())) { if (parser.parseKeyword("predicate")) return ::mlir::failure(); if (parser.parseEqual()) return ::mlir::failure(); { predicateOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); predicateOperands.push_back(operand); } } } { 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 (::mlir::succeeded(parser.parseOptionalArrow())) { if (parser.parseTypeList(writeOnlyArgsTypes)) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({static_cast(readOnlyArgsOperands.size()), static_cast(readWriteArgsOperands.size()), static_cast(predicateOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); result.addTypes(writeOnlyArgsTypes); if (parser.resolveOperands(readOnlyArgsOperands, readOnlyArgsTypes, readOnlyArgsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(readWriteArgsOperands, readWriteArgsTypes, readWriteArgsOperandsLoc, result.operands)) return ::mlir::failure(); if (!predicateOperands.empty()) { if (parser.resolveOperands(predicateOperands, odsBuildableType0, predicateOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void InlinePtxOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getPtxCodeAttr()); if (!getReadOnlyArgs().empty()) { _odsPrinter << ' ' << "ro"; _odsPrinter << "("; _odsPrinter << getReadOnlyArgs(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getReadOnlyArgs().getTypes(); _odsPrinter << ")"; } if (!getReadWriteArgs().empty()) { _odsPrinter << ' ' << "rw"; _odsPrinter << "("; _odsPrinter << getReadWriteArgs(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getReadWriteArgs().getTypes(); _odsPrinter << ")"; } if (getPredicate()) { _odsPrinter << ","; _odsPrinter << ' ' << "predicate"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getPredicate()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("ptxCode"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); if (!getWriteOnlyArgs().empty()) { _odsPrinter << ' ' << "->"; _odsPrinter << ' '; _odsPrinter << getWriteOnlyArgs().getTypes(); } } std::string InlinePtxOp::getPtx() { StringRef ptxInstStr = getPtxCode(); return std::string(ptxInstStr.data()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::InlinePtxOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::InlinePtxOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::LaneIdOp definitions //===----------------------------------------------------------------------===// namespace detail { LaneIdOpGenericAdaptorBase::LaneIdOpGenericAdaptorBase(LaneIdOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> LaneIdOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail LaneIdOpAdaptor::LaneIdOpAdaptor(LaneIdOp op) : LaneIdOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult LaneIdOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.laneid' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult LaneIdOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute LaneIdOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code LaneIdOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional LaneIdOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void LaneIdOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void LaneIdOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult LaneIdOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult LaneIdOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void LaneIdOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> LaneIdOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void LaneIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } LaneIdOp LaneIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneIdOp LaneIdOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void LaneIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } LaneIdOp LaneIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneIdOp LaneIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void LaneIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneIdOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } LaneIdOp LaneIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneIdOp LaneIdOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void LaneIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } LaneIdOp LaneIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneIdOp LaneIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void LaneIdOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } LaneIdOp LaneIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneIdOp LaneIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void LaneIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneIdOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } LaneIdOp LaneIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneIdOp LaneIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void LaneIdOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } LaneIdOp LaneIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneIdOp LaneIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void LaneIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneIdOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } LaneIdOp LaneIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneIdOp LaneIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult LaneIdOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult LaneIdOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult LaneIdOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult LaneIdOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void LaneIdOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void LaneIdOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void LaneIdOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult LaneIdOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::LaneIdOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::LaneIdOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::LaneMaskEqOp definitions //===----------------------------------------------------------------------===// namespace detail { LaneMaskEqOpGenericAdaptorBase::LaneMaskEqOpGenericAdaptorBase(LaneMaskEqOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail LaneMaskEqOpAdaptor::LaneMaskEqOpAdaptor(LaneMaskEqOp op) : LaneMaskEqOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult LaneMaskEqOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult LaneMaskEqOp::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 LaneMaskEqOp::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 LaneMaskEqOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional LaneMaskEqOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void LaneMaskEqOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void LaneMaskEqOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult LaneMaskEqOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void LaneMaskEqOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } LaneMaskEqOp LaneMaskEqOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskEqOp LaneMaskEqOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void LaneMaskEqOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneMaskEqOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } LaneMaskEqOp LaneMaskEqOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskEqOp LaneMaskEqOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void LaneMaskEqOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } LaneMaskEqOp LaneMaskEqOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskEqOp LaneMaskEqOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void LaneMaskEqOp::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); } LaneMaskEqOp LaneMaskEqOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskEqOp LaneMaskEqOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void LaneMaskEqOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneMaskEqOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } LaneMaskEqOp LaneMaskEqOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskEqOp LaneMaskEqOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void LaneMaskEqOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } LaneMaskEqOp LaneMaskEqOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskEqOp LaneMaskEqOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void LaneMaskEqOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneMaskEqOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } LaneMaskEqOp LaneMaskEqOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskEqOp LaneMaskEqOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult LaneMaskEqOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult LaneMaskEqOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult LaneMaskEqOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult LaneMaskEqOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void LaneMaskEqOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void LaneMaskEqOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::LaneMaskEqOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::LaneMaskGeOp definitions //===----------------------------------------------------------------------===// namespace detail { LaneMaskGeOpGenericAdaptorBase::LaneMaskGeOpGenericAdaptorBase(LaneMaskGeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail LaneMaskGeOpAdaptor::LaneMaskGeOpAdaptor(LaneMaskGeOp op) : LaneMaskGeOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult LaneMaskGeOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult LaneMaskGeOp::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 LaneMaskGeOp::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 LaneMaskGeOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional LaneMaskGeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void LaneMaskGeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void LaneMaskGeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult LaneMaskGeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void LaneMaskGeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } LaneMaskGeOp LaneMaskGeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskGeOp LaneMaskGeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void LaneMaskGeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneMaskGeOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } LaneMaskGeOp LaneMaskGeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskGeOp LaneMaskGeOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void LaneMaskGeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } LaneMaskGeOp LaneMaskGeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskGeOp LaneMaskGeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void LaneMaskGeOp::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); } LaneMaskGeOp LaneMaskGeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskGeOp LaneMaskGeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void LaneMaskGeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneMaskGeOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } LaneMaskGeOp LaneMaskGeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskGeOp LaneMaskGeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void LaneMaskGeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } LaneMaskGeOp LaneMaskGeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskGeOp LaneMaskGeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void LaneMaskGeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneMaskGeOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } LaneMaskGeOp LaneMaskGeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskGeOp LaneMaskGeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult LaneMaskGeOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult LaneMaskGeOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult LaneMaskGeOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult LaneMaskGeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void LaneMaskGeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void LaneMaskGeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::LaneMaskGeOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::LaneMaskGtOp definitions //===----------------------------------------------------------------------===// namespace detail { LaneMaskGtOpGenericAdaptorBase::LaneMaskGtOpGenericAdaptorBase(LaneMaskGtOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail LaneMaskGtOpAdaptor::LaneMaskGtOpAdaptor(LaneMaskGtOp op) : LaneMaskGtOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult LaneMaskGtOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult LaneMaskGtOp::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 LaneMaskGtOp::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 LaneMaskGtOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional LaneMaskGtOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void LaneMaskGtOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void LaneMaskGtOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult LaneMaskGtOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void LaneMaskGtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } LaneMaskGtOp LaneMaskGtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskGtOp LaneMaskGtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void LaneMaskGtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneMaskGtOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } LaneMaskGtOp LaneMaskGtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskGtOp LaneMaskGtOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void LaneMaskGtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } LaneMaskGtOp LaneMaskGtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskGtOp LaneMaskGtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void LaneMaskGtOp::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); } LaneMaskGtOp LaneMaskGtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskGtOp LaneMaskGtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void LaneMaskGtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneMaskGtOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } LaneMaskGtOp LaneMaskGtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskGtOp LaneMaskGtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void LaneMaskGtOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } LaneMaskGtOp LaneMaskGtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskGtOp LaneMaskGtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void LaneMaskGtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneMaskGtOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } LaneMaskGtOp LaneMaskGtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskGtOp LaneMaskGtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult LaneMaskGtOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult LaneMaskGtOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult LaneMaskGtOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult LaneMaskGtOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void LaneMaskGtOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void LaneMaskGtOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::LaneMaskGtOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::LaneMaskLeOp definitions //===----------------------------------------------------------------------===// namespace detail { LaneMaskLeOpGenericAdaptorBase::LaneMaskLeOpGenericAdaptorBase(LaneMaskLeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail LaneMaskLeOpAdaptor::LaneMaskLeOpAdaptor(LaneMaskLeOp op) : LaneMaskLeOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult LaneMaskLeOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult LaneMaskLeOp::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 LaneMaskLeOp::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 LaneMaskLeOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional LaneMaskLeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void LaneMaskLeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void LaneMaskLeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult LaneMaskLeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void LaneMaskLeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } LaneMaskLeOp LaneMaskLeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskLeOp LaneMaskLeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void LaneMaskLeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneMaskLeOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } LaneMaskLeOp LaneMaskLeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskLeOp LaneMaskLeOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void LaneMaskLeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } LaneMaskLeOp LaneMaskLeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskLeOp LaneMaskLeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void LaneMaskLeOp::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); } LaneMaskLeOp LaneMaskLeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskLeOp LaneMaskLeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void LaneMaskLeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneMaskLeOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } LaneMaskLeOp LaneMaskLeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskLeOp LaneMaskLeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void LaneMaskLeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } LaneMaskLeOp LaneMaskLeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskLeOp LaneMaskLeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void LaneMaskLeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneMaskLeOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } LaneMaskLeOp LaneMaskLeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskLeOp LaneMaskLeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult LaneMaskLeOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult LaneMaskLeOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult LaneMaskLeOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult LaneMaskLeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void LaneMaskLeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void LaneMaskLeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::LaneMaskLeOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::LaneMaskLtOp definitions //===----------------------------------------------------------------------===// namespace detail { LaneMaskLtOpGenericAdaptorBase::LaneMaskLtOpGenericAdaptorBase(LaneMaskLtOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail LaneMaskLtOpAdaptor::LaneMaskLtOpAdaptor(LaneMaskLtOp op) : LaneMaskLtOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult LaneMaskLtOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult LaneMaskLtOp::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 LaneMaskLtOp::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 LaneMaskLtOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional LaneMaskLtOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void LaneMaskLtOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void LaneMaskLtOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult LaneMaskLtOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void LaneMaskLtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } LaneMaskLtOp LaneMaskLtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskLtOp LaneMaskLtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void LaneMaskLtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneMaskLtOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } LaneMaskLtOp LaneMaskLtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskLtOp LaneMaskLtOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void LaneMaskLtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } LaneMaskLtOp LaneMaskLtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskLtOp LaneMaskLtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void LaneMaskLtOp::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); } LaneMaskLtOp LaneMaskLtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskLtOp LaneMaskLtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void LaneMaskLtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneMaskLtOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } LaneMaskLtOp LaneMaskLtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskLtOp LaneMaskLtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void LaneMaskLtOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } LaneMaskLtOp LaneMaskLtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskLtOp LaneMaskLtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void LaneMaskLtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LaneMaskLtOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } LaneMaskLtOp LaneMaskLtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LaneMaskLtOp LaneMaskLtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult LaneMaskLtOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult LaneMaskLtOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult LaneMaskLtOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult LaneMaskLtOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void LaneMaskLtOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void LaneMaskLtOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::LaneMaskLtOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::LdMatrixOp definitions //===----------------------------------------------------------------------===// namespace detail { LdMatrixOpGenericAdaptorBase::LdMatrixOpGenericAdaptorBase(LdMatrixOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} uint32_t LdMatrixOpGenericAdaptorBase::getNum() { auto attr = getNumAttr(); return attr.getValue().getZExtValue(); } ::mlir::NVVM::MMALayout LdMatrixOpGenericAdaptorBase::getLayout() { auto attr = getLayoutAttr(); return attr.getValue(); } ::mlir::NVVM::LdStMatrixShapeAttr LdMatrixOpGenericAdaptorBase::getShape() { auto attr = getShapeAttr(); return ::llvm::cast<::mlir::NVVM::LdStMatrixShapeAttr>(attr); } ::mlir::NVVM::LdStMatrixEltType LdMatrixOpGenericAdaptorBase::getEltType() { auto attr = getEltTypeAttr(); return attr.getValue(); } } // namespace detail LdMatrixOpAdaptor::LdMatrixOpAdaptor(LdMatrixOp op) : LdMatrixOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult LdMatrixOpAdaptor::verify(::mlir::Location loc) { auto tblgen_eltType = getProperties().eltType; (void)tblgen_eltType; if (!tblgen_eltType) return emitError(loc, "'nvvm.ldmatrix' op requires attribute 'eltType'"); auto tblgen_layout = getProperties().layout; (void)tblgen_layout; if (!tblgen_layout) return emitError(loc, "'nvvm.ldmatrix' op requires attribute 'layout'"); auto tblgen_num = getProperties().num; (void)tblgen_num; if (!tblgen_num) return emitError(loc, "'nvvm.ldmatrix' op requires attribute 'num'"); auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitError(loc, "'nvvm.ldmatrix' op requires attribute 'shape'"); if (tblgen_num && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_num))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_num).getType().isSignlessInteger(32))))) return emitError(loc, "'nvvm.ldmatrix' op attribute 'num' failed to satisfy constraint: 32-bit signless integer attribute"); if (tblgen_layout && !((::llvm::isa<::mlir::NVVM::MMALayoutAttr>(tblgen_layout)))) return emitError(loc, "'nvvm.ldmatrix' op attribute 'layout' failed to satisfy constraint: NVVM MMA layout"); if (tblgen_shape && !((::llvm::isa<::mlir::NVVM::LdStMatrixShapeAttr>(tblgen_shape)))) return emitError(loc, "'nvvm.ldmatrix' op attribute 'shape' failed to satisfy constraint: Matrix shape for ldmatrix and stmatrix"); if (tblgen_eltType && !((::llvm::isa<::mlir::NVVM::LdStMatrixEltTypeAttr>(tblgen_eltType)))) return emitError(loc, "'nvvm.ldmatrix' op attribute 'eltType' failed to satisfy constraint: Element type for ldmatrix and stmatrix"); return ::mlir::success(); } ::llvm::LogicalResult LdMatrixOp::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.eltType; auto attr = dict.get("eltType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `eltType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.layout; auto attr = dict.get("layout"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `layout` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.num; auto attr = dict.get("num"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `num` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.shape; auto attr = dict.get("shape"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `shape` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute LdMatrixOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.eltType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("eltType", propStorage)); } { const auto &propStorage = prop.layout; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("layout", propStorage)); } { const auto &propStorage = prop.num; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("num", propStorage)); } { const auto &propStorage = prop.shape; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("shape", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code LdMatrixOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.eltType.getAsOpaquePointer()), llvm::hash_value(prop.layout.getAsOpaquePointer()), llvm::hash_value(prop.num.getAsOpaquePointer()), llvm::hash_value(prop.shape.getAsOpaquePointer())); } std::optional LdMatrixOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "eltType") return prop.eltType; if (name == "layout") return prop.layout; if (name == "num") return prop.num; if (name == "shape") return prop.shape; return std::nullopt; } void LdMatrixOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "eltType") { prop.eltType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "layout") { prop.layout = ::llvm::dyn_cast_or_null>(value); return; } if (name == "num") { prop.num = ::llvm::dyn_cast_or_null>(value); return; } if (name == "shape") { prop.shape = ::llvm::dyn_cast_or_null>(value); return; } } void LdMatrixOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.eltType) attrs.append("eltType", prop.eltType); if (prop.layout) attrs.append("layout", prop.layout); if (prop.num) attrs.append("num", prop.num); if (prop.shape) attrs.append("shape", prop.shape); } ::llvm::LogicalResult LdMatrixOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getEltTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps36(attr, "eltType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getLayoutAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(attr, "layout", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNumAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(attr, "num", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getShapeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps35(attr, "shape", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult LdMatrixOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.eltType))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.layout))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.num))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.shape))) return ::mlir::failure(); return ::mlir::success(); } void LdMatrixOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.eltType); writer.writeAttribute(prop.layout); writer.writeAttribute(prop.num); writer.writeAttribute(prop.shape); } uint32_t LdMatrixOp::getNum() { auto attr = getNumAttr(); return attr.getValue().getZExtValue(); } ::mlir::NVVM::MMALayout LdMatrixOp::getLayout() { auto attr = getLayoutAttr(); return attr.getValue(); } ::mlir::NVVM::LdStMatrixShapeAttr LdMatrixOp::getShape() { auto attr = getShapeAttr(); return ::llvm::cast<::mlir::NVVM::LdStMatrixShapeAttr>(attr); } ::mlir::NVVM::LdStMatrixEltType LdMatrixOp::getEltType() { auto attr = getEltTypeAttr(); return attr.getValue(); } void LdMatrixOp::setNum(uint32_t attrValue) { getProperties().num = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); } void LdMatrixOp::setLayout(::mlir::NVVM::MMALayout attrValue) { getProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void LdMatrixOp::setEltType(::mlir::NVVM::LdStMatrixEltType attrValue) { getProperties().eltType = ::mlir::NVVM::LdStMatrixEltTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void LdMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value ptr, ::mlir::IntegerAttr num, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { odsState.addOperands(ptr); odsState.getOrAddProperties().num = num; odsState.getOrAddProperties().layout = layout; odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().eltType = eltType; odsState.addTypes(res); } LdMatrixOp LdMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value ptr, ::mlir::IntegerAttr num, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(ptr), std::forward(num), std::forward(layout), std::forward(shape), std::forward(eltType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LdMatrixOp LdMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value ptr, ::mlir::IntegerAttr num, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { return create(builder, builder.getLoc(), std::forward(res), std::forward(ptr), std::forward(num), std::forward(layout), std::forward(shape), std::forward(eltType)); } void LdMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value ptr, ::mlir::IntegerAttr num, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { odsState.addOperands(ptr); odsState.getOrAddProperties().num = num; odsState.getOrAddProperties().layout = layout; odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().eltType = eltType; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LdMatrixOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } LdMatrixOp LdMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value ptr, ::mlir::IntegerAttr num, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(ptr), std::forward(num), std::forward(layout), std::forward(shape), std::forward(eltType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LdMatrixOp LdMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value ptr, ::mlir::IntegerAttr num, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { return create(builder, builder.getLoc(), std::forward(ptr), std::forward(num), std::forward(layout), std::forward(shape), std::forward(eltType)); } void LdMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::IntegerAttr num, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { odsState.addOperands(ptr); odsState.getOrAddProperties().num = num; odsState.getOrAddProperties().layout = layout; odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().eltType = eltType; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } LdMatrixOp LdMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::IntegerAttr num, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ptr), std::forward(num), std::forward(layout), std::forward(shape), std::forward(eltType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LdMatrixOp LdMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::IntegerAttr num, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ptr), std::forward(num), std::forward(layout), std::forward(shape), std::forward(eltType)); } void LdMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value ptr, uint32_t num, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltType eltType) { odsState.addOperands(ptr); odsState.getOrAddProperties().num = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), num); odsState.getOrAddProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layout); odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().eltType = ::mlir::NVVM::LdStMatrixEltTypeAttr::get(odsBuilder.getContext(), eltType); odsState.addTypes(res); } LdMatrixOp LdMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value ptr, uint32_t num, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltType eltType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(ptr), std::forward(num), std::forward(layout), std::forward(shape), std::forward(eltType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LdMatrixOp LdMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value ptr, uint32_t num, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltType eltType) { return create(builder, builder.getLoc(), std::forward(res), std::forward(ptr), std::forward(num), std::forward(layout), std::forward(shape), std::forward(eltType)); } void LdMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value ptr, uint32_t num, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltType eltType) { odsState.addOperands(ptr); odsState.getOrAddProperties().num = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), num); odsState.getOrAddProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layout); odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().eltType = ::mlir::NVVM::LdStMatrixEltTypeAttr::get(odsBuilder.getContext(), eltType); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LdMatrixOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } LdMatrixOp LdMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value ptr, uint32_t num, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltType eltType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(ptr), std::forward(num), std::forward(layout), std::forward(shape), std::forward(eltType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LdMatrixOp LdMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value ptr, uint32_t num, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltType eltType) { return create(builder, builder.getLoc(), std::forward(ptr), std::forward(num), std::forward(layout), std::forward(shape), std::forward(eltType)); } void LdMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, uint32_t num, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltType eltType) { odsState.addOperands(ptr); odsState.getOrAddProperties().num = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), num); odsState.getOrAddProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layout); odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().eltType = ::mlir::NVVM::LdStMatrixEltTypeAttr::get(odsBuilder.getContext(), eltType); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } LdMatrixOp LdMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, uint32_t num, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltType eltType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ptr), std::forward(num), std::forward(layout), std::forward(shape), std::forward(eltType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LdMatrixOp LdMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, uint32_t num, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltType eltType) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ptr), std::forward(num), std::forward(layout), std::forward(shape), std::forward(eltType)); } void LdMatrixOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } LdMatrixOp LdMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LdMatrixOp LdMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void LdMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LdMatrixOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } LdMatrixOp LdMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LdMatrixOp LdMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void LdMatrixOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } LdMatrixOp LdMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LdMatrixOp LdMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void LdMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LdMatrixOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } LdMatrixOp LdMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LdMatrixOp LdMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult LdMatrixOp::verifyInvariantsImpl() { auto tblgen_eltType = getProperties().eltType; (void)tblgen_eltType; if (!tblgen_eltType) return emitOpError("requires attribute 'eltType'"); auto tblgen_layout = getProperties().layout; (void)tblgen_layout; if (!tblgen_layout) return emitOpError("requires attribute 'layout'"); auto tblgen_num = getProperties().num; (void)tblgen_num; if (!tblgen_num) return emitOpError("requires attribute 'num'"); auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitOpError("requires attribute 'shape'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(*this, tblgen_num, "num"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(*this, tblgen_layout, "layout"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps35(*this, tblgen_shape, "shape"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps36(*this, tblgen_eltType, "eltType"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps7(*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_NVVMOps28(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult LdMatrixOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult LdMatrixOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand ptrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> ptrOperands(&ptrRawOperand, 1); ::llvm::SMLoc ptrOperandsLoc; (void)ptrOperandsLoc; ::llvm::ArrayRef<::mlir::Type> ptrTypes; ::llvm::ArrayRef<::mlir::Type> resTypes; ptrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(ptrRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); ::mlir::FunctionType ptr__res_functionType; if (parser.parseType(ptr__res_functionType)) return ::mlir::failure(); ptrTypes = ptr__res_functionType.getInputs(); resTypes = ptr__res_functionType.getResults(); result.addTypes(resTypes); if (parser.resolveOperands(ptrOperands, ptrTypes, ptrOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void LdMatrixOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getPtr(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter.printFunctionalType(::llvm::ArrayRef<::mlir::Type>(getPtr().getType()), ::llvm::ArrayRef<::mlir::Type>(getRes().getType())); } ::llvm::LogicalResult LdMatrixOp::inferReturnTypes(::mlir::MLIRContext *context, std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { LdMatrixOp::Adaptor adaptor(operands, attributes, properties, regions); return LdMatrixOp::inferReturnTypes(context, location, adaptor, inferredReturnTypes); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::LdMatrixOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::LdMatrixOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Log2Op definitions //===----------------------------------------------------------------------===// namespace detail { Log2OpGenericAdaptorBase::Log2OpGenericAdaptorBase(Log2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::BoolAttr Log2OpGenericAdaptorBase::getFtzAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().ftz); return attr; } bool Log2OpGenericAdaptorBase::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } } // namespace detail Log2OpAdaptor::Log2OpAdaptor(Log2Op op) : Log2OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Log2OpAdaptor::verify(::mlir::Location loc) { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; if (tblgen_ftz && !((::llvm::isa<::mlir::BoolAttr>(tblgen_ftz)))) return emitError(loc, "'nvvm.log2' op attribute 'ftz' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult Log2Op::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.ftz; auto attr = dict.get("ftz"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ftz` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Log2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.ftz; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ftz", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Log2Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.ftz.getAsOpaquePointer())); } std::optional Log2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "ftz") return prop.ftz; return std::nullopt; } void Log2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "ftz") { prop.ftz = ::llvm::dyn_cast_or_null>(value); return; } } void Log2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.ftz) attrs.append("ftz", prop.ftz); } ::llvm::LogicalResult Log2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFtzAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "ftz", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Log2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.ftz))) return ::mlir::failure(); return ::mlir::success(); } void Log2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.ftz); } bool Log2Op::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } void Log2Op::setFtz(bool attrValue) { getProperties().ftz = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void Log2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } odsState.addTypes(res); } Log2Op Log2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Log2Op Log2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(src), std::forward(ftz)); } void Log2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(Log2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } Log2Op Log2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Log2Op Log2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(src), std::forward(ftz)); } void Log2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } Log2Op Log2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Log2Op Log2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(ftz)); } void Log2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); odsState.addTypes(res); } Log2Op Log2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Log2Op Log2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(src), std::forward(ftz)); } void Log2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(Log2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } Log2Op Log2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Log2Op Log2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(src), std::forward(ftz)); } void Log2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } Log2Op Log2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Log2Op Log2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(ftz)); } void Log2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Log2Op Log2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Log2Op Log2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Log2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(Log2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } Log2Op Log2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Log2Op Log2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void Log2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Log2Op Log2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Log2Op Log2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Log2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(Log2Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } Log2Op Log2Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Log2Op Log2Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Log2Op::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.ftz) properties.ftz = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult Log2Op::verifyInvariantsImpl() { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_ftz, "ftz"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*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_NVVMOps13(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Log2Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult Log2Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); if (operands.size() <= 0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[0].getType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult Log2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) 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::FloatType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } result.addTypes(srcTypes[0]); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void Log2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFtzAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("ftz"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::FloatType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void Log2Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Log2Op) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Log2OpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MBarrierArriveDropExpectTxOp definitions //===----------------------------------------------------------------------===// namespace detail { MBarrierArriveDropExpectTxOpGenericAdaptorBase::MBarrierArriveDropExpectTxOpGenericAdaptorBase(MBarrierArriveDropExpectTxOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::MemScopeKindAttr MBarrierArriveDropExpectTxOpGenericAdaptorBase::getScopeAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::MemScopeKindAttr>(getProperties().scope); return attr; } ::mlir::NVVM::MemScopeKind MBarrierArriveDropExpectTxOpGenericAdaptorBase::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } ::mlir::BoolAttr MBarrierArriveDropExpectTxOpGenericAdaptorBase::getRelaxedAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relaxed); return attr; } bool MBarrierArriveDropExpectTxOpGenericAdaptorBase::getRelaxed() { auto attr = getRelaxedAttr(); return attr.getValue(); } } // namespace detail MBarrierArriveDropExpectTxOpAdaptor::MBarrierArriveDropExpectTxOpAdaptor(MBarrierArriveDropExpectTxOp op) : MBarrierArriveDropExpectTxOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MBarrierArriveDropExpectTxOpAdaptor::verify(::mlir::Location loc) { auto tblgen_relaxed = getProperties().relaxed; (void)tblgen_relaxed; auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (tblgen_scope && !((::llvm::isa<::mlir::NVVM::MemScopeKindAttr>(tblgen_scope)))) return emitError(loc, "'nvvm.mbarrier.arrive_drop.expect_tx' op attribute 'scope' failed to satisfy constraint: NVVM Memory Scope kind"); if (tblgen_relaxed && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relaxed)))) return emitError(loc, "'nvvm.mbarrier.arrive_drop.expect_tx' op attribute 'relaxed' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair MBarrierArriveDropExpectTxOp::getODSResultIndexAndLength(unsigned index) { bool isVariadic[] = {true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumResults() - 0) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::llvm::LogicalResult MBarrierArriveDropExpectTxOp::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.relaxed; auto attr = dict.get("relaxed"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relaxed` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.scope; auto attr = dict.get("scope"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scope` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MBarrierArriveDropExpectTxOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relaxed; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relaxed", propStorage)); } { const auto &propStorage = prop.scope; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("scope", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MBarrierArriveDropExpectTxOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relaxed.getAsOpaquePointer()), llvm::hash_value(prop.scope.getAsOpaquePointer())); } std::optional MBarrierArriveDropExpectTxOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relaxed") return prop.relaxed; if (name == "scope") return prop.scope; return std::nullopt; } void MBarrierArriveDropExpectTxOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relaxed") { prop.relaxed = ::llvm::dyn_cast_or_null>(value); return; } if (name == "scope") { prop.scope = ::llvm::dyn_cast_or_null>(value); return; } } void MBarrierArriveDropExpectTxOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relaxed) attrs.append("relaxed", prop.relaxed); if (prop.scope) attrs.append("scope", prop.scope); } ::llvm::LogicalResult MBarrierArriveDropExpectTxOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRelaxedAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relaxed", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getScopeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(attr, "scope", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MBarrierArriveDropExpectTxOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relaxed))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.scope))) return ::mlir::failure(); return ::mlir::success(); } void MBarrierArriveDropExpectTxOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relaxed); writer.writeOptionalAttribute(prop.scope); } ::mlir::NVVM::MemScopeKind MBarrierArriveDropExpectTxOp::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } bool MBarrierArriveDropExpectTxOp::getRelaxed() { auto attr = getRelaxedAttr(); return attr.getValue(); } void MBarrierArriveDropExpectTxOp::setScope(::mlir::NVVM::MemScopeKind attrValue) { getProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MBarrierArriveDropExpectTxOp::setRelaxed(bool attrValue) { getProperties().relaxed = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void MBarrierArriveDropExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type res, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { odsState.addOperands(addr); odsState.addOperands(txcount); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } if (res) odsState.addTypes(res); } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Type res, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Type res, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { return create(builder, builder.getLoc(), std::forward(res), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveDropExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { odsState.addOperands(addr); odsState.addOperands(txcount); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveDropExpectTxOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveDropExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { odsState.addOperands(addr); odsState.addOperands(txcount); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } odsState.addTypes(resultTypes); } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveDropExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type res, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { odsState.addOperands(addr); odsState.addOperands(txcount); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); if (res) odsState.addTypes(res); } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Type res, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Type res, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { return create(builder, builder.getLoc(), std::forward(res), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveDropExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { odsState.addOperands(addr); odsState.addOperands(txcount); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveDropExpectTxOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveDropExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { odsState.addOperands(addr); odsState.addOperands(txcount); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); odsState.addTypes(resultTypes); } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveDropExpectTxOp::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); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MBarrierArriveDropExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveDropExpectTxOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MBarrierArriveDropExpectTxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); odsState.addTypes(resultTypes); } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MBarrierArriveDropExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveDropExpectTxOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropExpectTxOp MBarrierArriveDropExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MBarrierArriveDropExpectTxOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.scope) properties.scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), MemScopeKind::CTA); if (!properties.relaxed) properties.relaxed = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult MBarrierArriveDropExpectTxOp::verifyInvariantsImpl() { auto tblgen_relaxed = getProperties().relaxed; (void)tblgen_relaxed; auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(*this, tblgen_scope, "scope"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relaxed, "relaxed"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps29(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); if (valueGroup0.size() > 1) { return emitOpError("result 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_NVVMOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MBarrierArriveDropExpectTxOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult MBarrierArriveDropExpectTxOp::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 txcountRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> txcountOperands(&txcountRawOperand, 1); ::llvm::SMLoc txcountOperandsLoc; (void)txcountOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; ::llvm::SmallVector<::mlir::Type, 1> resTypes; addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); txcountOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(txcountRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalArrow())) { { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); resTypes.push_back(optionalType); } } } result.addTypes(resTypes); if (parser.resolveOperands(::llvm::concat(addrOperands, txcountOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MBarrierArriveDropExpectTxOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getTxcount(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getScopeAttr(); if(attr && (attr == ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), MemScopeKind::CTA))) elidedAttrs.push_back("scope"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getRelaxedAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relaxed"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); if (getRes()) { _odsPrinter << ' ' << "->"; _odsPrinter << ' '; _odsPrinter << (getRes() ? ::llvm::ArrayRef<::mlir::Type>(getRes().getType()) : ::llvm::ArrayRef<::mlir::Type>()); } } ::llvm::LogicalResult MBarrierArriveDropExpectTxOp::inferReturnTypes(::mlir::MLIRContext *context, std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { MBarrierArriveDropExpectTxOp::Adaptor adaptor(operands, attributes, properties, regions); return MBarrierArriveDropExpectTxOp::inferReturnTypes(context, location, adaptor, inferredReturnTypes); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MBarrierArriveDropExpectTxOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::MBarrierArriveDropExpectTxOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MBarrierArriveDropNocompleteOp definitions //===----------------------------------------------------------------------===// namespace detail { MBarrierArriveDropNocompleteOpGenericAdaptorBase::MBarrierArriveDropNocompleteOpGenericAdaptorBase(MBarrierArriveDropNocompleteOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail MBarrierArriveDropNocompleteOpAdaptor::MBarrierArriveDropNocompleteOpAdaptor(MBarrierArriveDropNocompleteOp op) : MBarrierArriveDropNocompleteOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MBarrierArriveDropNocompleteOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult MBarrierArriveDropNocompleteOp::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 MBarrierArriveDropNocompleteOp::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 MBarrierArriveDropNocompleteOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional MBarrierArriveDropNocompleteOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void MBarrierArriveDropNocompleteOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void MBarrierArriveDropNocompleteOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult MBarrierArriveDropNocompleteOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void MBarrierArriveDropNocompleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value count) { odsState.addOperands(addr); odsState.addOperands(count); odsState.addTypes(res); } MBarrierArriveDropNocompleteOp MBarrierArriveDropNocompleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value count) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(addr), std::forward(count)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropNocompleteOp MBarrierArriveDropNocompleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value count) { return create(builder, builder.getLoc(), std::forward(res), std::forward(addr), std::forward(count)); } void MBarrierArriveDropNocompleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value count) { odsState.addOperands(addr); odsState.addOperands(count); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveDropNocompleteOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MBarrierArriveDropNocompleteOp MBarrierArriveDropNocompleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value count) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(count)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropNocompleteOp MBarrierArriveDropNocompleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value count) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(count)); } void MBarrierArriveDropNocompleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value count) { odsState.addOperands(addr); odsState.addOperands(count); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MBarrierArriveDropNocompleteOp MBarrierArriveDropNocompleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value count) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(count)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropNocompleteOp MBarrierArriveDropNocompleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value count) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(count)); } void MBarrierArriveDropNocompleteOp::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); } MBarrierArriveDropNocompleteOp MBarrierArriveDropNocompleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropNocompleteOp MBarrierArriveDropNocompleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MBarrierArriveDropNocompleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveDropNocompleteOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MBarrierArriveDropNocompleteOp MBarrierArriveDropNocompleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropNocompleteOp MBarrierArriveDropNocompleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MBarrierArriveDropNocompleteOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MBarrierArriveDropNocompleteOp MBarrierArriveDropNocompleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropNocompleteOp MBarrierArriveDropNocompleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MBarrierArriveDropNocompleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveDropNocompleteOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MBarrierArriveDropNocompleteOp MBarrierArriveDropNocompleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropNocompleteOp MBarrierArriveDropNocompleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult MBarrierArriveDropNocompleteOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps3(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MBarrierArriveDropNocompleteOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult MBarrierArriveDropNocompleteOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(64); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult MBarrierArriveDropNocompleteOp::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 countRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> countOperands(&countRawOperand, 1); ::llvm::SMLoc countOperandsLoc; (void)countOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); countOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(countRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); if (parser.resolveOperands(::llvm::concat(addrOperands, countOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MBarrierArriveDropNocompleteOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getCount(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MBarrierArriveDropNocompleteOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MBarrierArriveDropOp definitions //===----------------------------------------------------------------------===// namespace detail { MBarrierArriveDropOpGenericAdaptorBase::MBarrierArriveDropOpGenericAdaptorBase(MBarrierArriveDropOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair MBarrierArriveDropOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::NVVM::MemScopeKindAttr MBarrierArriveDropOpGenericAdaptorBase::getScopeAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::MemScopeKindAttr>(getProperties().scope); return attr; } ::mlir::NVVM::MemScopeKind MBarrierArriveDropOpGenericAdaptorBase::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } ::mlir::BoolAttr MBarrierArriveDropOpGenericAdaptorBase::getRelaxedAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relaxed); return attr; } bool MBarrierArriveDropOpGenericAdaptorBase::getRelaxed() { auto attr = getRelaxedAttr(); return attr.getValue(); } } // namespace detail MBarrierArriveDropOpAdaptor::MBarrierArriveDropOpAdaptor(MBarrierArriveDropOp op) : MBarrierArriveDropOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MBarrierArriveDropOpAdaptor::verify(::mlir::Location loc) { auto tblgen_relaxed = getProperties().relaxed; (void)tblgen_relaxed; auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (tblgen_scope && !((::llvm::isa<::mlir::NVVM::MemScopeKindAttr>(tblgen_scope)))) return emitError(loc, "'nvvm.mbarrier.arrive_drop' op attribute 'scope' failed to satisfy constraint: NVVM Memory Scope kind"); if (tblgen_relaxed && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relaxed)))) return emitError(loc, "'nvvm.mbarrier.arrive_drop' op attribute 'relaxed' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair MBarrierArriveDropOp::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 MBarrierArriveDropOp::getCountMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } std::pair MBarrierArriveDropOp::getODSResultIndexAndLength(unsigned index) { bool isVariadic[] = {true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumResults() - 0) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::llvm::LogicalResult MBarrierArriveDropOp::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.relaxed; auto attr = dict.get("relaxed"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relaxed` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.scope; auto attr = dict.get("scope"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scope` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MBarrierArriveDropOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relaxed; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relaxed", propStorage)); } { const auto &propStorage = prop.scope; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("scope", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MBarrierArriveDropOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relaxed.getAsOpaquePointer()), llvm::hash_value(prop.scope.getAsOpaquePointer())); } std::optional MBarrierArriveDropOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relaxed") return prop.relaxed; if (name == "scope") return prop.scope; return std::nullopt; } void MBarrierArriveDropOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relaxed") { prop.relaxed = ::llvm::dyn_cast_or_null>(value); return; } if (name == "scope") { prop.scope = ::llvm::dyn_cast_or_null>(value); return; } } void MBarrierArriveDropOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relaxed) attrs.append("relaxed", prop.relaxed); if (prop.scope) attrs.append("scope", prop.scope); } ::llvm::LogicalResult MBarrierArriveDropOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRelaxedAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relaxed", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getScopeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(attr, "scope", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MBarrierArriveDropOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relaxed))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.scope))) return ::mlir::failure(); return ::mlir::success(); } void MBarrierArriveDropOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relaxed); writer.writeOptionalAttribute(prop.scope); } ::mlir::NVVM::MemScopeKind MBarrierArriveDropOp::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } bool MBarrierArriveDropOp::getRelaxed() { auto attr = getRelaxedAttr(); return attr.getValue(); } void MBarrierArriveDropOp::setScope(::mlir::NVVM::MemScopeKind attrValue) { getProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MBarrierArriveDropOp::setRelaxed(bool attrValue) { getProperties().relaxed = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void MBarrierArriveDropOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type res, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { odsState.addOperands(addr); if (count) odsState.addOperands(count); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } if (res) odsState.addTypes(res); } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Type res, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Type res, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { return create(builder, builder.getLoc(), std::forward(res), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveDropOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { odsState.addOperands(addr); if (count) odsState.addOperands(count); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveDropOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveDropOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { odsState.addOperands(addr); if (count) odsState.addOperands(count); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } odsState.addTypes(resultTypes); } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveDropOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type res, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { odsState.addOperands(addr); if (count) odsState.addOperands(count); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); if (res) odsState.addTypes(res); } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Type res, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Type res, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { return create(builder, builder.getLoc(), std::forward(res), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveDropOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { odsState.addOperands(addr); if (count) odsState.addOperands(count); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveDropOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveDropOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { odsState.addOperands(addr); if (count) odsState.addOperands(count); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); odsState.addTypes(resultTypes); } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveDropOp::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); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MBarrierArriveDropOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveDropOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MBarrierArriveDropOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); odsState.addTypes(resultTypes); } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MBarrierArriveDropOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveDropOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveDropOp MBarrierArriveDropOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MBarrierArriveDropOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.scope) properties.scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), MemScopeKind::CTA); if (!properties.relaxed) properties.relaxed = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult MBarrierArriveDropOp::verifyInvariantsImpl() { auto tblgen_relaxed = getProperties().relaxed; (void)tblgen_relaxed; auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(*this, tblgen_scope, "scope"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relaxed, "relaxed"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps29(*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_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); if (valueGroup0.size() > 1) { return emitOpError("result 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_NVVMOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MBarrierArriveDropOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult MBarrierArriveDropOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand addrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> addrOperands(&addrRawOperand, 1); ::llvm::SMLoc addrOperandsLoc; (void)addrOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> countOperands; ::llvm::SMLoc countOperandsLoc; (void)countOperandsLoc; ::mlir::Type addrRawType{}; ::llvm::ArrayRef<::mlir::Type> addrTypes(&addrRawType, 1); ::llvm::SmallVector<::mlir::Type, 1> resTypes; addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { countOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); countOperands.push_back(operand); } } } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); addrRawType = type; } if (::mlir::succeeded(parser.parseOptionalArrow())) { { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); resTypes.push_back(optionalType); } } } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); result.addTypes(resTypes); if (parser.resolveOperands(addrOperands, addrTypes, addrOperandsLoc, result.operands)) return ::mlir::failure(); if (!countOperands.empty()) { if (parser.resolveOperands(countOperands, odsBuildableType0, countOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void MBarrierArriveDropOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); if (getCount()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getCount()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getScopeAttr(); if(attr && (attr == ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), MemScopeKind::CTA))) elidedAttrs.push_back("scope"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getRelaxedAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relaxed"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getAddr().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } if (getRes()) { _odsPrinter << ' ' << "->"; _odsPrinter << ' '; _odsPrinter << (getRes() ? ::llvm::ArrayRef<::mlir::Type>(getRes().getType()) : ::llvm::ArrayRef<::mlir::Type>()); } } ::llvm::LogicalResult MBarrierArriveDropOp::inferReturnTypes(::mlir::MLIRContext *context, std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { MBarrierArriveDropOp::Adaptor adaptor(operands, attributes, properties, regions); return MBarrierArriveDropOp::inferReturnTypes(context, location, adaptor, inferredReturnTypes); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MBarrierArriveDropOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::MBarrierArriveDropOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MBarrierArriveExpectTxOp definitions //===----------------------------------------------------------------------===// namespace detail { MBarrierArriveExpectTxOpGenericAdaptorBase::MBarrierArriveExpectTxOpGenericAdaptorBase(MBarrierArriveExpectTxOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair MBarrierArriveExpectTxOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::NVVM::MemScopeKindAttr MBarrierArriveExpectTxOpGenericAdaptorBase::getScopeAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::MemScopeKindAttr>(getProperties().scope); return attr; } ::mlir::NVVM::MemScopeKind MBarrierArriveExpectTxOpGenericAdaptorBase::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } ::mlir::BoolAttr MBarrierArriveExpectTxOpGenericAdaptorBase::getRelaxedAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relaxed); return attr; } bool MBarrierArriveExpectTxOpGenericAdaptorBase::getRelaxed() { auto attr = getRelaxedAttr(); return attr.getValue(); } } // namespace detail MBarrierArriveExpectTxOpAdaptor::MBarrierArriveExpectTxOpAdaptor(MBarrierArriveExpectTxOp op) : MBarrierArriveExpectTxOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MBarrierArriveExpectTxOpAdaptor::verify(::mlir::Location loc) { auto tblgen_relaxed = getProperties().relaxed; (void)tblgen_relaxed; auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (tblgen_scope && !((::llvm::isa<::mlir::NVVM::MemScopeKindAttr>(tblgen_scope)))) return emitError(loc, "'nvvm.mbarrier.arrive.expect_tx' op attribute 'scope' failed to satisfy constraint: NVVM Memory Scope kind"); if (tblgen_relaxed && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relaxed)))) return emitError(loc, "'nvvm.mbarrier.arrive.expect_tx' op attribute 'relaxed' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair MBarrierArriveExpectTxOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange MBarrierArriveExpectTxOp::getPredicateMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } std::pair MBarrierArriveExpectTxOp::getODSResultIndexAndLength(unsigned index) { bool isVariadic[] = {true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumResults() - 0) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::llvm::LogicalResult MBarrierArriveExpectTxOp::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.relaxed; auto attr = dict.get("relaxed"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relaxed` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.scope; auto attr = dict.get("scope"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scope` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MBarrierArriveExpectTxOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relaxed; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relaxed", propStorage)); } { const auto &propStorage = prop.scope; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("scope", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MBarrierArriveExpectTxOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relaxed.getAsOpaquePointer()), llvm::hash_value(prop.scope.getAsOpaquePointer())); } std::optional MBarrierArriveExpectTxOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relaxed") return prop.relaxed; if (name == "scope") return prop.scope; return std::nullopt; } void MBarrierArriveExpectTxOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relaxed") { prop.relaxed = ::llvm::dyn_cast_or_null>(value); return; } if (name == "scope") { prop.scope = ::llvm::dyn_cast_or_null>(value); return; } } void MBarrierArriveExpectTxOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relaxed) attrs.append("relaxed", prop.relaxed); if (prop.scope) attrs.append("scope", prop.scope); } ::llvm::LogicalResult MBarrierArriveExpectTxOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRelaxedAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relaxed", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getScopeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(attr, "scope", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MBarrierArriveExpectTxOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relaxed))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.scope))) return ::mlir::failure(); return ::mlir::success(); } void MBarrierArriveExpectTxOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relaxed); writer.writeOptionalAttribute(prop.scope); } ::mlir::NVVM::MemScopeKind MBarrierArriveExpectTxOp::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } bool MBarrierArriveExpectTxOp::getRelaxed() { auto attr = getRelaxedAttr(); return attr.getValue(); } void MBarrierArriveExpectTxOp::setScope(::mlir::NVVM::MemScopeKind attrValue) { getProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MBarrierArriveExpectTxOp::setRelaxed(bool attrValue) { getProperties().relaxed = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void MBarrierArriveExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type res, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed, /*optional*/::mlir::Value predicate) { odsState.addOperands(addr); odsState.addOperands(txcount); if (predicate) odsState.addOperands(predicate); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } if (res) odsState.addTypes(res); } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Type res, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Type res, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(res), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed), std::forward(predicate)); } void MBarrierArriveExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed, /*optional*/::mlir::Value predicate) { odsState.addOperands(addr); odsState.addOperands(txcount); if (predicate) odsState.addOperands(predicate); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveExpectTxOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed), std::forward(predicate)); } void MBarrierArriveExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed, /*optional*/::mlir::Value predicate) { odsState.addOperands(addr); odsState.addOperands(txcount); if (predicate) odsState.addOperands(predicate); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } odsState.addTypes(resultTypes); } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed), std::forward(predicate)); } void MBarrierArriveExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type res, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed, /*optional*/::mlir::Value predicate) { odsState.addOperands(addr); odsState.addOperands(txcount); if (predicate) odsState.addOperands(predicate); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); if (res) odsState.addTypes(res); } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Type res, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Type res, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(res), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed), std::forward(predicate)); } void MBarrierArriveExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed, /*optional*/::mlir::Value predicate) { odsState.addOperands(addr); odsState.addOperands(txcount); if (predicate) odsState.addOperands(predicate); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveExpectTxOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed), std::forward(predicate)); } void MBarrierArriveExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed, /*optional*/::mlir::Value predicate) { odsState.addOperands(addr); odsState.addOperands(txcount); if (predicate) odsState.addOperands(predicate); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); odsState.addTypes(resultTypes); } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope, bool relaxed, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(txcount), std::forward(scope), std::forward(relaxed), std::forward(predicate)); } void MBarrierArriveExpectTxOp::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); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MBarrierArriveExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveExpectTxOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MBarrierArriveExpectTxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); odsState.addTypes(resultTypes); } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MBarrierArriveExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveExpectTxOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveExpectTxOp MBarrierArriveExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MBarrierArriveExpectTxOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.scope) properties.scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), MemScopeKind::CTA); if (!properties.relaxed) properties.relaxed = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult MBarrierArriveExpectTxOp::verifyInvariantsImpl() { auto tblgen_relaxed = getProperties().relaxed; (void)tblgen_relaxed; auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(*this, tblgen_scope, "scope"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relaxed, "relaxed"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps29(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps23(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); if (valueGroup0.size() > 1) { return emitOpError("result 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_NVVMOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MBarrierArriveExpectTxOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult MBarrierArriveExpectTxOp::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 txcountRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> txcountOperands(&txcountRawOperand, 1); ::llvm::SMLoc txcountOperandsLoc; (void)txcountOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> predicateOperands; ::llvm::SMLoc predicateOperandsLoc; (void)predicateOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; ::llvm::SmallVector<::mlir::Type, 1> resTypes; addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); txcountOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(txcountRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { if (parser.parseKeyword("predicate")) return ::mlir::failure(); if (parser.parseEqual()) return ::mlir::failure(); { predicateOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); predicateOperands.push_back(operand); } } } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalArrow())) { { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); resTypes.push_back(optionalType); } } } result.addTypes(resTypes); if (parser.resolveOperands(::llvm::concat(addrOperands, txcountOperands, predicateOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MBarrierArriveExpectTxOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getTxcount(); if (getPredicate()) { _odsPrinter << ","; _odsPrinter << ' ' << "predicate"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getPredicate()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getScopeAttr(); if(attr && (attr == ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), MemScopeKind::CTA))) elidedAttrs.push_back("scope"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getRelaxedAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relaxed"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); if (getRes()) { _odsPrinter << ' ' << "->"; _odsPrinter << ' '; _odsPrinter << (getRes() ? ::llvm::ArrayRef<::mlir::Type>(getRes().getType()) : ::llvm::ArrayRef<::mlir::Type>()); } } ::llvm::LogicalResult MBarrierArriveExpectTxOp::inferReturnTypes(::mlir::MLIRContext *context, std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { MBarrierArriveExpectTxOp::Adaptor adaptor(operands, attributes, properties, regions); return MBarrierArriveExpectTxOp::inferReturnTypes(context, location, adaptor, inferredReturnTypes); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MBarrierArriveExpectTxOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::MBarrierArriveExpectTxOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MBarrierArriveNocompleteOp definitions //===----------------------------------------------------------------------===// namespace detail { MBarrierArriveNocompleteOpGenericAdaptorBase::MBarrierArriveNocompleteOpGenericAdaptorBase(MBarrierArriveNocompleteOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail MBarrierArriveNocompleteOpAdaptor::MBarrierArriveNocompleteOpAdaptor(MBarrierArriveNocompleteOp op) : MBarrierArriveNocompleteOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MBarrierArriveNocompleteOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult MBarrierArriveNocompleteOp::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 MBarrierArriveNocompleteOp::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 MBarrierArriveNocompleteOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional MBarrierArriveNocompleteOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void MBarrierArriveNocompleteOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void MBarrierArriveNocompleteOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult MBarrierArriveNocompleteOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void MBarrierArriveNocompleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value count) { odsState.addOperands(addr); odsState.addOperands(count); odsState.addTypes(res); } MBarrierArriveNocompleteOp MBarrierArriveNocompleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value count) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(addr), std::forward(count)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveNocompleteOp MBarrierArriveNocompleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value count) { return create(builder, builder.getLoc(), std::forward(res), std::forward(addr), std::forward(count)); } void MBarrierArriveNocompleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value count) { odsState.addOperands(addr); odsState.addOperands(count); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveNocompleteOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MBarrierArriveNocompleteOp MBarrierArriveNocompleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value count) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(count)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveNocompleteOp MBarrierArriveNocompleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value count) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(count)); } void MBarrierArriveNocompleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value count) { odsState.addOperands(addr); odsState.addOperands(count); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MBarrierArriveNocompleteOp MBarrierArriveNocompleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value count) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(count)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveNocompleteOp MBarrierArriveNocompleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value count) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(count)); } void MBarrierArriveNocompleteOp::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); } MBarrierArriveNocompleteOp MBarrierArriveNocompleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveNocompleteOp MBarrierArriveNocompleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MBarrierArriveNocompleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveNocompleteOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MBarrierArriveNocompleteOp MBarrierArriveNocompleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveNocompleteOp MBarrierArriveNocompleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MBarrierArriveNocompleteOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MBarrierArriveNocompleteOp MBarrierArriveNocompleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveNocompleteOp MBarrierArriveNocompleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MBarrierArriveNocompleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveNocompleteOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MBarrierArriveNocompleteOp MBarrierArriveNocompleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveNocompleteOp MBarrierArriveNocompleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult MBarrierArriveNocompleteOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps3(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MBarrierArriveNocompleteOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult MBarrierArriveNocompleteOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(64); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult MBarrierArriveNocompleteOp::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 countRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> countOperands(&countRawOperand, 1); ::llvm::SMLoc countOperandsLoc; (void)countOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); countOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(countRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); if (parser.resolveOperands(::llvm::concat(addrOperands, countOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MBarrierArriveNocompleteOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getCount(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MBarrierArriveNocompleteOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MBarrierArriveOp definitions //===----------------------------------------------------------------------===// namespace detail { MBarrierArriveOpGenericAdaptorBase::MBarrierArriveOpGenericAdaptorBase(MBarrierArriveOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair MBarrierArriveOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::NVVM::MemScopeKindAttr MBarrierArriveOpGenericAdaptorBase::getScopeAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::MemScopeKindAttr>(getProperties().scope); return attr; } ::mlir::NVVM::MemScopeKind MBarrierArriveOpGenericAdaptorBase::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } ::mlir::BoolAttr MBarrierArriveOpGenericAdaptorBase::getRelaxedAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relaxed); return attr; } bool MBarrierArriveOpGenericAdaptorBase::getRelaxed() { auto attr = getRelaxedAttr(); return attr.getValue(); } } // namespace detail MBarrierArriveOpAdaptor::MBarrierArriveOpAdaptor(MBarrierArriveOp op) : MBarrierArriveOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MBarrierArriveOpAdaptor::verify(::mlir::Location loc) { auto tblgen_relaxed = getProperties().relaxed; (void)tblgen_relaxed; auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (tblgen_scope && !((::llvm::isa<::mlir::NVVM::MemScopeKindAttr>(tblgen_scope)))) return emitError(loc, "'nvvm.mbarrier.arrive' op attribute 'scope' failed to satisfy constraint: NVVM Memory Scope kind"); if (tblgen_relaxed && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relaxed)))) return emitError(loc, "'nvvm.mbarrier.arrive' op attribute 'relaxed' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair MBarrierArriveOp::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 MBarrierArriveOp::getCountMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } std::pair MBarrierArriveOp::getODSResultIndexAndLength(unsigned index) { bool isVariadic[] = {true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumResults() - 0) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::llvm::LogicalResult MBarrierArriveOp::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.relaxed; auto attr = dict.get("relaxed"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relaxed` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.scope; auto attr = dict.get("scope"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scope` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MBarrierArriveOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relaxed; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relaxed", propStorage)); } { const auto &propStorage = prop.scope; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("scope", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MBarrierArriveOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relaxed.getAsOpaquePointer()), llvm::hash_value(prop.scope.getAsOpaquePointer())); } std::optional MBarrierArriveOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relaxed") return prop.relaxed; if (name == "scope") return prop.scope; return std::nullopt; } void MBarrierArriveOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relaxed") { prop.relaxed = ::llvm::dyn_cast_or_null>(value); return; } if (name == "scope") { prop.scope = ::llvm::dyn_cast_or_null>(value); return; } } void MBarrierArriveOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relaxed) attrs.append("relaxed", prop.relaxed); if (prop.scope) attrs.append("scope", prop.scope); } ::llvm::LogicalResult MBarrierArriveOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRelaxedAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relaxed", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getScopeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(attr, "scope", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MBarrierArriveOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relaxed))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.scope))) return ::mlir::failure(); return ::mlir::success(); } void MBarrierArriveOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relaxed); writer.writeOptionalAttribute(prop.scope); } ::mlir::NVVM::MemScopeKind MBarrierArriveOp::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } bool MBarrierArriveOp::getRelaxed() { auto attr = getRelaxedAttr(); return attr.getValue(); } void MBarrierArriveOp::setScope(::mlir::NVVM::MemScopeKind attrValue) { getProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MBarrierArriveOp::setRelaxed(bool attrValue) { getProperties().relaxed = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void MBarrierArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type res, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { odsState.addOperands(addr); if (count) odsState.addOperands(count); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } if (res) odsState.addTypes(res); } MBarrierArriveOp MBarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Type res, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveOp MBarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Type res, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { return create(builder, builder.getLoc(), std::forward(res), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { odsState.addOperands(addr); if (count) odsState.addOperands(count); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MBarrierArriveOp MBarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveOp MBarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { odsState.addOperands(addr); if (count) odsState.addOperands(count); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } odsState.addTypes(resultTypes); } MBarrierArriveOp MBarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveOp MBarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type res, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { odsState.addOperands(addr); if (count) odsState.addOperands(count); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); if (res) odsState.addTypes(res); } MBarrierArriveOp MBarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Type res, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveOp MBarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Type res, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { return create(builder, builder.getLoc(), std::forward(res), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { odsState.addOperands(addr); if (count) odsState.addOperands(count); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MBarrierArriveOp MBarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveOp MBarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { odsState.addOperands(addr); if (count) odsState.addOperands(count); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); odsState.addTypes(resultTypes); } MBarrierArriveOp MBarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveOp MBarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value count, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(count), std::forward(scope), std::forward(relaxed)); } void MBarrierArriveOp::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); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } MBarrierArriveOp MBarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveOp MBarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MBarrierArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MBarrierArriveOp MBarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveOp MBarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MBarrierArriveOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); odsState.addTypes(resultTypes); } MBarrierArriveOp MBarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveOp MBarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MBarrierArriveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierArriveOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MBarrierArriveOp MBarrierArriveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierArriveOp MBarrierArriveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MBarrierArriveOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.scope) properties.scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), MemScopeKind::CTA); if (!properties.relaxed) properties.relaxed = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult MBarrierArriveOp::verifyInvariantsImpl() { auto tblgen_relaxed = getProperties().relaxed; (void)tblgen_relaxed; auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(*this, tblgen_scope, "scope"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relaxed, "relaxed"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps29(*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_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); if (valueGroup0.size() > 1) { return emitOpError("result 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_NVVMOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MBarrierArriveOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult MBarrierArriveOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand addrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> addrOperands(&addrRawOperand, 1); ::llvm::SMLoc addrOperandsLoc; (void)addrOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> countOperands; ::llvm::SMLoc countOperandsLoc; (void)countOperandsLoc; ::mlir::Type addrRawType{}; ::llvm::ArrayRef<::mlir::Type> addrTypes(&addrRawType, 1); ::llvm::SmallVector<::mlir::Type, 1> resTypes; addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { countOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); countOperands.push_back(operand); } } } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); addrRawType = type; } if (::mlir::succeeded(parser.parseOptionalArrow())) { { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); resTypes.push_back(optionalType); } } } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); result.addTypes(resTypes); if (parser.resolveOperands(addrOperands, addrTypes, addrOperandsLoc, result.operands)) return ::mlir::failure(); if (!countOperands.empty()) { if (parser.resolveOperands(countOperands, odsBuildableType0, countOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void MBarrierArriveOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); if (getCount()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getCount()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getScopeAttr(); if(attr && (attr == ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), MemScopeKind::CTA))) elidedAttrs.push_back("scope"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getRelaxedAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relaxed"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getAddr().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } if (getRes()) { _odsPrinter << ' ' << "->"; _odsPrinter << ' '; _odsPrinter << (getRes() ? ::llvm::ArrayRef<::mlir::Type>(getRes().getType()) : ::llvm::ArrayRef<::mlir::Type>()); } } ::llvm::LogicalResult MBarrierArriveOp::inferReturnTypes(::mlir::MLIRContext *context, std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { MBarrierArriveOp::Adaptor adaptor(operands, attributes, properties, regions); return MBarrierArriveOp::inferReturnTypes(context, location, adaptor, inferredReturnTypes); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MBarrierArriveOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::MBarrierArriveOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MBarrierCompleteTxOp definitions //===----------------------------------------------------------------------===// namespace detail { MBarrierCompleteTxOpGenericAdaptorBase::MBarrierCompleteTxOpGenericAdaptorBase(MBarrierCompleteTxOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::MemScopeKindAttr MBarrierCompleteTxOpGenericAdaptorBase::getScopeAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::MemScopeKindAttr>(getProperties().scope); return attr; } ::mlir::NVVM::MemScopeKind MBarrierCompleteTxOpGenericAdaptorBase::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } } // namespace detail MBarrierCompleteTxOpAdaptor::MBarrierCompleteTxOpAdaptor(MBarrierCompleteTxOp op) : MBarrierCompleteTxOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MBarrierCompleteTxOpAdaptor::verify(::mlir::Location loc) { auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (tblgen_scope && !((::llvm::isa<::mlir::NVVM::MemScopeKindAttr>(tblgen_scope)))) return emitError(loc, "'nvvm.mbarrier.complete_tx' op attribute 'scope' failed to satisfy constraint: NVVM Memory Scope kind"); return ::mlir::success(); } ::llvm::LogicalResult MBarrierCompleteTxOp::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.scope; auto attr = dict.get("scope"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scope` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MBarrierCompleteTxOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.scope; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("scope", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MBarrierCompleteTxOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.scope.getAsOpaquePointer())); } std::optional MBarrierCompleteTxOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "scope") return prop.scope; return std::nullopt; } void MBarrierCompleteTxOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "scope") { prop.scope = ::llvm::dyn_cast_or_null>(value); return; } } void MBarrierCompleteTxOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.scope) attrs.append("scope", prop.scope); } ::llvm::LogicalResult MBarrierCompleteTxOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getScopeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(attr, "scope", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MBarrierCompleteTxOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.scope))) return ::mlir::failure(); return ::mlir::success(); } void MBarrierCompleteTxOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.scope); } ::mlir::NVVM::MemScopeKind MBarrierCompleteTxOp::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } void MBarrierCompleteTxOp::setScope(::mlir::NVVM::MemScopeKind attrValue) { getProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MBarrierCompleteTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope) { odsState.addOperands(addr); odsState.addOperands(txcount); if (scope) { odsState.getOrAddProperties().scope = scope; } } MBarrierCompleteTxOp MBarrierCompleteTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(txcount), std::forward(scope)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierCompleteTxOp MBarrierCompleteTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(txcount), std::forward(scope)); } void MBarrierCompleteTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope) { odsState.addOperands(addr); odsState.addOperands(txcount); if (scope) { odsState.getOrAddProperties().scope = scope; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } MBarrierCompleteTxOp MBarrierCompleteTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(txcount), std::forward(scope)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierCompleteTxOp MBarrierCompleteTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(txcount), std::forward(scope)); } void MBarrierCompleteTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope) { odsState.addOperands(addr); odsState.addOperands(txcount); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); } MBarrierCompleteTxOp MBarrierCompleteTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(txcount), std::forward(scope)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierCompleteTxOp MBarrierCompleteTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(txcount), std::forward(scope)); } void MBarrierCompleteTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope) { odsState.addOperands(addr); odsState.addOperands(txcount); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } MBarrierCompleteTxOp MBarrierCompleteTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(txcount), std::forward(scope)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierCompleteTxOp MBarrierCompleteTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(txcount), std::forward(scope)); } void MBarrierCompleteTxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } MBarrierCompleteTxOp MBarrierCompleteTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierCompleteTxOp MBarrierCompleteTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MBarrierCompleteTxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MBarrierCompleteTxOp MBarrierCompleteTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierCompleteTxOp MBarrierCompleteTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MBarrierCompleteTxOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.scope) properties.scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), MemScopeKind::CTA); } ::llvm::LogicalResult MBarrierCompleteTxOp::verifyInvariantsImpl() { auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(*this, tblgen_scope, "scope"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps17(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MBarrierCompleteTxOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult MBarrierCompleteTxOp::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 txcountRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> txcountOperands(&txcountRawOperand, 1); ::llvm::SMLoc txcountOperandsLoc; (void)txcountOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); txcountOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(txcountRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.resolveOperands(::llvm::concat(addrOperands, txcountOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MBarrierCompleteTxOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getTxcount(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getScopeAttr(); if(attr && (attr == ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), MemScopeKind::CTA))) elidedAttrs.push_back("scope"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MBarrierCompleteTxOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::MBarrierCompleteTxOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MBarrierExpectTxOp definitions //===----------------------------------------------------------------------===// namespace detail { MBarrierExpectTxOpGenericAdaptorBase::MBarrierExpectTxOpGenericAdaptorBase(MBarrierExpectTxOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::MemScopeKindAttr MBarrierExpectTxOpGenericAdaptorBase::getScopeAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::MemScopeKindAttr>(getProperties().scope); return attr; } ::mlir::NVVM::MemScopeKind MBarrierExpectTxOpGenericAdaptorBase::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } } // namespace detail MBarrierExpectTxOpAdaptor::MBarrierExpectTxOpAdaptor(MBarrierExpectTxOp op) : MBarrierExpectTxOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MBarrierExpectTxOpAdaptor::verify(::mlir::Location loc) { auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (tblgen_scope && !((::llvm::isa<::mlir::NVVM::MemScopeKindAttr>(tblgen_scope)))) return emitError(loc, "'nvvm.mbarrier.expect_tx' op attribute 'scope' failed to satisfy constraint: NVVM Memory Scope kind"); return ::mlir::success(); } ::llvm::LogicalResult MBarrierExpectTxOp::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.scope; auto attr = dict.get("scope"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scope` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MBarrierExpectTxOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.scope; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("scope", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MBarrierExpectTxOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.scope.getAsOpaquePointer())); } std::optional MBarrierExpectTxOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "scope") return prop.scope; return std::nullopt; } void MBarrierExpectTxOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "scope") { prop.scope = ::llvm::dyn_cast_or_null>(value); return; } } void MBarrierExpectTxOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.scope) attrs.append("scope", prop.scope); } ::llvm::LogicalResult MBarrierExpectTxOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getScopeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(attr, "scope", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MBarrierExpectTxOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.scope))) return ::mlir::failure(); return ::mlir::success(); } void MBarrierExpectTxOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.scope); } ::mlir::NVVM::MemScopeKind MBarrierExpectTxOp::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } void MBarrierExpectTxOp::setScope(::mlir::NVVM::MemScopeKind attrValue) { getProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MBarrierExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope) { odsState.addOperands(addr); odsState.addOperands(txcount); if (scope) { odsState.getOrAddProperties().scope = scope; } } MBarrierExpectTxOp MBarrierExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(txcount), std::forward(scope)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierExpectTxOp MBarrierExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(txcount), std::forward(scope)); } void MBarrierExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope) { odsState.addOperands(addr); odsState.addOperands(txcount); if (scope) { odsState.getOrAddProperties().scope = scope; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } MBarrierExpectTxOp MBarrierExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(txcount), std::forward(scope)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierExpectTxOp MBarrierExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKindAttr scope) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(txcount), std::forward(scope)); } void MBarrierExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope) { odsState.addOperands(addr); odsState.addOperands(txcount); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); } MBarrierExpectTxOp MBarrierExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(txcount), std::forward(scope)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierExpectTxOp MBarrierExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(txcount), std::forward(scope)); } void MBarrierExpectTxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope) { odsState.addOperands(addr); odsState.addOperands(txcount); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } MBarrierExpectTxOp MBarrierExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(txcount), std::forward(scope)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierExpectTxOp MBarrierExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value txcount, ::mlir::NVVM::MemScopeKind scope) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(txcount), std::forward(scope)); } void MBarrierExpectTxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } MBarrierExpectTxOp MBarrierExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierExpectTxOp MBarrierExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MBarrierExpectTxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MBarrierExpectTxOp MBarrierExpectTxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierExpectTxOp MBarrierExpectTxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MBarrierExpectTxOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.scope) properties.scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), MemScopeKind::CTA); } ::llvm::LogicalResult MBarrierExpectTxOp::verifyInvariantsImpl() { auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(*this, tblgen_scope, "scope"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps17(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MBarrierExpectTxOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult MBarrierExpectTxOp::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 txcountRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> txcountOperands(&txcountRawOperand, 1); ::llvm::SMLoc txcountOperandsLoc; (void)txcountOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); txcountOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(txcountRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.resolveOperands(::llvm::concat(addrOperands, txcountOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MBarrierExpectTxOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getTxcount(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getScopeAttr(); if(attr && (attr == ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), MemScopeKind::CTA))) elidedAttrs.push_back("scope"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MBarrierExpectTxOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::MBarrierExpectTxOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MBarrierInitOp definitions //===----------------------------------------------------------------------===// namespace detail { MBarrierInitOpGenericAdaptorBase::MBarrierInitOpGenericAdaptorBase(MBarrierInitOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair MBarrierInitOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } } // namespace detail MBarrierInitOpAdaptor::MBarrierInitOpAdaptor(MBarrierInitOp op) : MBarrierInitOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MBarrierInitOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair MBarrierInitOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange MBarrierInitOp::getPredicateMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult MBarrierInitOp::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 MBarrierInitOp::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 MBarrierInitOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional MBarrierInitOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void MBarrierInitOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void MBarrierInitOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult MBarrierInitOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void MBarrierInitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value count, /*optional*/::mlir::Value predicate) { odsState.addOperands(addr); odsState.addOperands(count); if (predicate) odsState.addOperands(predicate); } MBarrierInitOp MBarrierInitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value count, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(count), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierInitOp MBarrierInitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value count, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(count), std::forward(predicate)); } void MBarrierInitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value count, /*optional*/::mlir::Value predicate) { odsState.addOperands(addr); odsState.addOperands(count); if (predicate) odsState.addOperands(predicate); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } MBarrierInitOp MBarrierInitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value count, /*optional*/::mlir::Value predicate) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(count), std::forward(predicate)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierInitOp MBarrierInitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value count, /*optional*/::mlir::Value predicate) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(count), std::forward(predicate)); } void MBarrierInitOp::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); } MBarrierInitOp MBarrierInitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierInitOp MBarrierInitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MBarrierInitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MBarrierInitOp MBarrierInitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierInitOp MBarrierInitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult MBarrierInitOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps3(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps23(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MBarrierInitOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult MBarrierInitOp::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 countRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> countOperands(&countRawOperand, 1); ::llvm::SMLoc countOperandsLoc; (void)countOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> predicateOperands; ::llvm::SMLoc predicateOperandsLoc; (void)predicateOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); countOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(countRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { if (parser.parseKeyword("predicate")) return ::mlir::failure(); if (parser.parseEqual()) return ::mlir::failure(); { predicateOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); predicateOperands.push_back(operand); } } } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.resolveOperands(::llvm::concat(addrOperands, countOperands, predicateOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MBarrierInitOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getCount(); if (getPredicate()) { _odsPrinter << ","; _odsPrinter << ' ' << "predicate"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getPredicate()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MBarrierInitOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MBarrierInvalOp definitions //===----------------------------------------------------------------------===// namespace detail { MBarrierInvalOpGenericAdaptorBase::MBarrierInvalOpGenericAdaptorBase(MBarrierInvalOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail MBarrierInvalOpAdaptor::MBarrierInvalOpAdaptor(MBarrierInvalOp op) : MBarrierInvalOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MBarrierInvalOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult MBarrierInvalOp::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 MBarrierInvalOp::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 MBarrierInvalOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional MBarrierInvalOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void MBarrierInvalOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void MBarrierInvalOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult MBarrierInvalOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void MBarrierInvalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr) { odsState.addOperands(addr); } MBarrierInvalOp MBarrierInvalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierInvalOp MBarrierInvalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr) { return create(builder, builder.getLoc(), std::forward(addr)); } void MBarrierInvalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr) { odsState.addOperands(addr); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } MBarrierInvalOp MBarrierInvalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierInvalOp MBarrierInvalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr)); } void MBarrierInvalOp::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); } MBarrierInvalOp MBarrierInvalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierInvalOp MBarrierInvalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MBarrierInvalOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MBarrierInvalOp MBarrierInvalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierInvalOp MBarrierInvalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult MBarrierInvalOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps3(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MBarrierInvalOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult MBarrierInvalOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand addrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> addrOperands(&addrRawOperand, 1); ::llvm::SMLoc addrOperandsLoc; (void)addrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.resolveOperands(addrOperands, allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MBarrierInvalOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MBarrierInvalOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MBarrierTestWaitOp definitions //===----------------------------------------------------------------------===// namespace detail { MBarrierTestWaitOpGenericAdaptorBase::MBarrierTestWaitOpGenericAdaptorBase(MBarrierTestWaitOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::MemScopeKindAttr MBarrierTestWaitOpGenericAdaptorBase::getScopeAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::MemScopeKindAttr>(getProperties().scope); return attr; } ::mlir::NVVM::MemScopeKind MBarrierTestWaitOpGenericAdaptorBase::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } ::mlir::BoolAttr MBarrierTestWaitOpGenericAdaptorBase::getRelaxedAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relaxed); return attr; } bool MBarrierTestWaitOpGenericAdaptorBase::getRelaxed() { auto attr = getRelaxedAttr(); return attr.getValue(); } } // namespace detail MBarrierTestWaitOpAdaptor::MBarrierTestWaitOpAdaptor(MBarrierTestWaitOp op) : MBarrierTestWaitOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MBarrierTestWaitOpAdaptor::verify(::mlir::Location loc) { auto tblgen_relaxed = getProperties().relaxed; (void)tblgen_relaxed; auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (tblgen_scope && !((::llvm::isa<::mlir::NVVM::MemScopeKindAttr>(tblgen_scope)))) return emitError(loc, "'nvvm.mbarrier.test.wait' op attribute 'scope' failed to satisfy constraint: NVVM Memory Scope kind"); if (tblgen_relaxed && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relaxed)))) return emitError(loc, "'nvvm.mbarrier.test.wait' op attribute 'relaxed' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult MBarrierTestWaitOp::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.relaxed; auto attr = dict.get("relaxed"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relaxed` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.scope; auto attr = dict.get("scope"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scope` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MBarrierTestWaitOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relaxed; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relaxed", propStorage)); } { const auto &propStorage = prop.scope; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("scope", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MBarrierTestWaitOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relaxed.getAsOpaquePointer()), llvm::hash_value(prop.scope.getAsOpaquePointer())); } std::optional MBarrierTestWaitOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relaxed") return prop.relaxed; if (name == "scope") return prop.scope; return std::nullopt; } void MBarrierTestWaitOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relaxed") { prop.relaxed = ::llvm::dyn_cast_or_null>(value); return; } if (name == "scope") { prop.scope = ::llvm::dyn_cast_or_null>(value); return; } } void MBarrierTestWaitOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relaxed) attrs.append("relaxed", prop.relaxed); if (prop.scope) attrs.append("scope", prop.scope); } ::llvm::LogicalResult MBarrierTestWaitOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRelaxedAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relaxed", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getScopeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(attr, "scope", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MBarrierTestWaitOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relaxed))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.scope))) return ::mlir::failure(); return ::mlir::success(); } void MBarrierTestWaitOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relaxed); writer.writeOptionalAttribute(prop.scope); } ::mlir::NVVM::MemScopeKind MBarrierTestWaitOp::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } bool MBarrierTestWaitOp::getRelaxed() { auto attr = getRelaxedAttr(); return attr.getValue(); } void MBarrierTestWaitOp::setScope(::mlir::NVVM::MemScopeKind attrValue) { getProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MBarrierTestWaitOp::setRelaxed(bool attrValue) { getProperties().relaxed = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void MBarrierTestWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { odsState.addOperands(addr); odsState.addOperands(stateOrPhase); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } odsState.addTypes(res); } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(addr), std::forward(stateOrPhase), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { return create(builder, builder.getLoc(), std::forward(res), std::forward(addr), std::forward(stateOrPhase), std::forward(scope), std::forward(relaxed)); } void MBarrierTestWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { odsState.addOperands(addr); odsState.addOperands(stateOrPhase); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierTestWaitOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(stateOrPhase), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(stateOrPhase), std::forward(scope), std::forward(relaxed)); } void MBarrierTestWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { odsState.addOperands(addr); odsState.addOperands(stateOrPhase); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(stateOrPhase), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(stateOrPhase), std::forward(scope), std::forward(relaxed)); } void MBarrierTestWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { odsState.addOperands(addr); odsState.addOperands(stateOrPhase); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); odsState.addTypes(res); } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(addr), std::forward(stateOrPhase), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { return create(builder, builder.getLoc(), std::forward(res), std::forward(addr), std::forward(stateOrPhase), std::forward(scope), std::forward(relaxed)); } void MBarrierTestWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { odsState.addOperands(addr); odsState.addOperands(stateOrPhase); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierTestWaitOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(stateOrPhase), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(stateOrPhase), std::forward(scope), std::forward(relaxed)); } void MBarrierTestWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { odsState.addOperands(addr); odsState.addOperands(stateOrPhase); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(stateOrPhase), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value stateOrPhase, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(stateOrPhase), std::forward(scope), std::forward(relaxed)); } void MBarrierTestWaitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MBarrierTestWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierTestWaitOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MBarrierTestWaitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MBarrierTestWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierTestWaitOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTestWaitOp MBarrierTestWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MBarrierTestWaitOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.scope) properties.scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), MemScopeKind::CTA); if (!properties.relaxed) properties.relaxed = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult MBarrierTestWaitOp::verifyInvariantsImpl() { auto tblgen_relaxed = getProperties().relaxed; (void)tblgen_relaxed; auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(*this, tblgen_scope, "scope"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relaxed, "relaxed"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps3(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps30(*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_NVVMOps23(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MBarrierTestWaitOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult MBarrierTestWaitOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(1); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult MBarrierTestWaitOp::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 stateOrPhaseRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> stateOrPhaseOperands(&stateOrPhaseRawOperand, 1); ::llvm::SMLoc stateOrPhaseOperandsLoc; (void)stateOrPhaseOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); stateOrPhaseOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(stateOrPhaseRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); if (parser.resolveOperands(::llvm::concat(addrOperands, stateOrPhaseOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MBarrierTestWaitOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getStateOrPhase(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getScopeAttr(); if(attr && (attr == ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), MemScopeKind::CTA))) elidedAttrs.push_back("scope"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getRelaxedAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relaxed"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MBarrierTestWaitOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::MBarrierTestWaitOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MBarrierTryWaitOp definitions //===----------------------------------------------------------------------===// namespace detail { MBarrierTryWaitOpGenericAdaptorBase::MBarrierTryWaitOpGenericAdaptorBase(MBarrierTryWaitOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair MBarrierTryWaitOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::NVVM::MemScopeKindAttr MBarrierTryWaitOpGenericAdaptorBase::getScopeAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::MemScopeKindAttr>(getProperties().scope); return attr; } ::mlir::NVVM::MemScopeKind MBarrierTryWaitOpGenericAdaptorBase::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } ::mlir::BoolAttr MBarrierTryWaitOpGenericAdaptorBase::getRelaxedAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().relaxed); return attr; } bool MBarrierTryWaitOpGenericAdaptorBase::getRelaxed() { auto attr = getRelaxedAttr(); return attr.getValue(); } } // namespace detail MBarrierTryWaitOpAdaptor::MBarrierTryWaitOpAdaptor(MBarrierTryWaitOp op) : MBarrierTryWaitOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MBarrierTryWaitOpAdaptor::verify(::mlir::Location loc) { auto tblgen_relaxed = getProperties().relaxed; (void)tblgen_relaxed; auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (tblgen_scope && !((::llvm::isa<::mlir::NVVM::MemScopeKindAttr>(tblgen_scope)))) return emitError(loc, "'nvvm.mbarrier.try_wait' op attribute 'scope' failed to satisfy constraint: NVVM Memory Scope kind"); if (tblgen_relaxed && !((::llvm::isa<::mlir::BoolAttr>(tblgen_relaxed)))) return emitError(loc, "'nvvm.mbarrier.try_wait' op attribute 'relaxed' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair MBarrierTryWaitOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange MBarrierTryWaitOp::getTicksMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult MBarrierTryWaitOp::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.relaxed; auto attr = dict.get("relaxed"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `relaxed` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.scope; auto attr = dict.get("scope"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scope` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MBarrierTryWaitOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.relaxed; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("relaxed", propStorage)); } { const auto &propStorage = prop.scope; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("scope", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MBarrierTryWaitOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.relaxed.getAsOpaquePointer()), llvm::hash_value(prop.scope.getAsOpaquePointer())); } std::optional MBarrierTryWaitOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "relaxed") return prop.relaxed; if (name == "scope") return prop.scope; return std::nullopt; } void MBarrierTryWaitOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "relaxed") { prop.relaxed = ::llvm::dyn_cast_or_null>(value); return; } if (name == "scope") { prop.scope = ::llvm::dyn_cast_or_null>(value); return; } } void MBarrierTryWaitOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.relaxed) attrs.append("relaxed", prop.relaxed); if (prop.scope) attrs.append("scope", prop.scope); } ::llvm::LogicalResult MBarrierTryWaitOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRelaxedAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "relaxed", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getScopeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(attr, "scope", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MBarrierTryWaitOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.relaxed))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.scope))) return ::mlir::failure(); return ::mlir::success(); } void MBarrierTryWaitOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.relaxed); writer.writeOptionalAttribute(prop.scope); } ::mlir::NVVM::MemScopeKind MBarrierTryWaitOp::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } bool MBarrierTryWaitOp::getRelaxed() { auto attr = getRelaxedAttr(); return attr.getValue(); } void MBarrierTryWaitOp::setScope(::mlir::NVVM::MemScopeKind attrValue) { getProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MBarrierTryWaitOp::setRelaxed(bool attrValue) { getProperties().relaxed = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void MBarrierTryWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { odsState.addOperands(addr); odsState.addOperands(stateOrPhase); if (ticks) odsState.addOperands(ticks); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } odsState.addTypes(res); } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(addr), std::forward(stateOrPhase), std::forward(ticks), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { return create(builder, builder.getLoc(), std::forward(res), std::forward(addr), std::forward(stateOrPhase), std::forward(ticks), std::forward(scope), std::forward(relaxed)); } void MBarrierTryWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { odsState.addOperands(addr); odsState.addOperands(stateOrPhase); if (ticks) odsState.addOperands(ticks); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierTryWaitOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(stateOrPhase), std::forward(ticks), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(stateOrPhase), std::forward(ticks), std::forward(scope), std::forward(relaxed)); } void MBarrierTryWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { odsState.addOperands(addr); odsState.addOperands(stateOrPhase); if (ticks) odsState.addOperands(ticks); if (scope) { odsState.getOrAddProperties().scope = scope; } if (relaxed) { odsState.getOrAddProperties().relaxed = relaxed; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(stateOrPhase), std::forward(ticks), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKindAttr scope, ::mlir::BoolAttr relaxed) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(stateOrPhase), std::forward(ticks), std::forward(scope), std::forward(relaxed)); } void MBarrierTryWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { odsState.addOperands(addr); odsState.addOperands(stateOrPhase); if (ticks) odsState.addOperands(ticks); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); odsState.addTypes(res); } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(addr), std::forward(stateOrPhase), std::forward(ticks), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { return create(builder, builder.getLoc(), std::forward(res), std::forward(addr), std::forward(stateOrPhase), std::forward(ticks), std::forward(scope), std::forward(relaxed)); } void MBarrierTryWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { odsState.addOperands(addr); odsState.addOperands(stateOrPhase); if (ticks) odsState.addOperands(ticks); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierTryWaitOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(stateOrPhase), std::forward(ticks), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(stateOrPhase), std::forward(ticks), std::forward(scope), std::forward(relaxed)); } void MBarrierTryWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { odsState.addOperands(addr); odsState.addOperands(stateOrPhase); if (ticks) odsState.addOperands(ticks); odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); odsState.getOrAddProperties().relaxed = odsBuilder.getBoolAttr(relaxed); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(stateOrPhase), std::forward(ticks), std::forward(scope), std::forward(relaxed)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value stateOrPhase, /*optional*/::mlir::Value ticks, ::mlir::NVVM::MemScopeKind scope, bool relaxed) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(stateOrPhase), std::forward(ticks), std::forward(scope), std::forward(relaxed)); } void MBarrierTryWaitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MBarrierTryWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierTryWaitOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MBarrierTryWaitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MBarrierTryWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MBarrierTryWaitOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTryWaitOp MBarrierTryWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MBarrierTryWaitOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.scope) properties.scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), MemScopeKind::CTA); if (!properties.relaxed) properties.relaxed = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult MBarrierTryWaitOp::verifyInvariantsImpl() { auto tblgen_relaxed = getProperties().relaxed; (void)tblgen_relaxed; auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(*this, tblgen_scope, "scope"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_relaxed, "relaxed"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps3(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps30(*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_NVVMOps2(*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_NVVMOps23(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MBarrierTryWaitOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult MBarrierTryWaitOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(1); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult MBarrierTryWaitOp::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 stateOrPhaseRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> stateOrPhaseOperands(&stateOrPhaseRawOperand, 1); ::llvm::SMLoc stateOrPhaseOperandsLoc; (void)stateOrPhaseOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ticksOperands; ::llvm::SMLoc ticksOperandsLoc; (void)ticksOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); stateOrPhaseOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(stateOrPhaseRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { ticksOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ticksOperands.push_back(operand); } } } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); if (parser.resolveOperands(::llvm::concat(addrOperands, stateOrPhaseOperands, ticksOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MBarrierTryWaitOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getStateOrPhase(); if (getTicks()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getTicks()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getScopeAttr(); if(attr && (attr == ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), MemScopeKind::CTA))) elidedAttrs.push_back("scope"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getRelaxedAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("relaxed"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MBarrierTryWaitOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::MBarrierTryWaitOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MBarrierTryWaitParityOp definitions //===----------------------------------------------------------------------===// namespace detail { MBarrierTryWaitParityOpGenericAdaptorBase::MBarrierTryWaitParityOpGenericAdaptorBase(MBarrierTryWaitParityOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail MBarrierTryWaitParityOpAdaptor::MBarrierTryWaitParityOpAdaptor(MBarrierTryWaitParityOp op) : MBarrierTryWaitParityOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MBarrierTryWaitParityOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult MBarrierTryWaitParityOp::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 MBarrierTryWaitParityOp::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 MBarrierTryWaitParityOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional MBarrierTryWaitParityOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void MBarrierTryWaitParityOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void MBarrierTryWaitParityOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult MBarrierTryWaitParityOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void MBarrierTryWaitParityOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value phase, ::mlir::Value ticks) { odsState.addOperands(addr); odsState.addOperands(phase); odsState.addOperands(ticks); } MBarrierTryWaitParityOp MBarrierTryWaitParityOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value phase, ::mlir::Value ticks) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(phase), std::forward(ticks)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTryWaitParityOp MBarrierTryWaitParityOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value phase, ::mlir::Value ticks) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(phase), std::forward(ticks)); } void MBarrierTryWaitParityOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value phase, ::mlir::Value ticks) { odsState.addOperands(addr); odsState.addOperands(phase); odsState.addOperands(ticks); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } MBarrierTryWaitParityOp MBarrierTryWaitParityOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value phase, ::mlir::Value ticks) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(phase), std::forward(ticks)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTryWaitParityOp MBarrierTryWaitParityOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value phase, ::mlir::Value ticks) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(phase), std::forward(ticks)); } void MBarrierTryWaitParityOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MBarrierTryWaitParityOp MBarrierTryWaitParityOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTryWaitParityOp MBarrierTryWaitParityOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MBarrierTryWaitParityOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MBarrierTryWaitParityOp MBarrierTryWaitParityOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MBarrierTryWaitParityOp MBarrierTryWaitParityOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult MBarrierTryWaitParityOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps3(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MBarrierTryWaitParityOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult MBarrierTryWaitParityOp::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 phaseRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> phaseOperands(&phaseRawOperand, 1); ::llvm::SMLoc phaseOperandsLoc; (void)phaseOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand ticksRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> ticksOperands(&ticksRawOperand, 1); ::llvm::SMLoc ticksOperandsLoc; (void)ticksOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); phaseOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(phaseRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); ticksOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(ticksRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.resolveOperands(::llvm::concat(addrOperands, phaseOperands, ticksOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MBarrierTryWaitParityOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getPhase(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getTicks(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MBarrierTryWaitParityOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MapaOp definitions //===----------------------------------------------------------------------===// namespace detail { MapaOpGenericAdaptorBase::MapaOpGenericAdaptorBase(MapaOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail MapaOpAdaptor::MapaOpAdaptor(MapaOp op) : MapaOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MapaOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult MapaOp::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 MapaOp::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 MapaOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional MapaOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void MapaOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void MapaOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult MapaOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void MapaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b) { odsState.addOperands(a); odsState.addOperands(b); odsState.addTypes(res); } MapaOp MapaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(a), std::forward(b)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MapaOp MapaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b) { return create(builder, builder.getLoc(), std::forward(res), std::forward(a), std::forward(b)); } void MapaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b) { odsState.addOperands(a); odsState.addOperands(b); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MapaOp MapaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(a), std::forward(b)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MapaOp MapaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(a), std::forward(b)); } void MapaOp::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); } MapaOp MapaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MapaOp MapaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MapaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MapaOp MapaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MapaOp MapaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult MapaOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps3(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps31(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!(((((::llvm::isa<::mlir::LLVM::LLVMPointerType>((*this->getODSOperands(0).begin()).getType()))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>((*this->getODSOperands(0).begin()).getType()).getAddressSpace() == 3))) && (((::llvm::isa<::mlir::LLVM::LLVMPointerType>((*this->getODSResults(0).begin()).getType()))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>((*this->getODSResults(0).begin()).getType()).getAddressSpace() == 7)))) || ((((::llvm::isa<::mlir::LLVM::LLVMPointerType>((*this->getODSOperands(0).begin()).getType()))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>((*this->getODSOperands(0).begin()).getType()).getAddressSpace() == 0))) && (((::llvm::isa<::mlir::LLVM::LLVMPointerType>((*this->getODSResults(0).begin()).getType()))) && ((::llvm::cast<::mlir::LLVM::LLVMPointerType>((*this->getODSResults(0).begin()).getType()).getAddressSpace() == 0)))))) return emitOpError("failed to verify that Valid address-space check(or mapping) for mapa Op"); return ::mlir::success(); } ::llvm::LogicalResult MapaOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult MapaOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand aRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(&aRawOperand, 1); ::llvm::SMLoc aOperandsLoc; (void)aOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand bRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> bOperands(&bRawOperand, 1); ::llvm::SMLoc bOperandsLoc; (void)bOperandsLoc; ::mlir::Type aRawType{}; ::llvm::ArrayRef<::mlir::Type> aTypes(&aRawType, 1); ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); aOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(aRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); bOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(bRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); aRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); result.addTypes(resTypes); if (parser.resolveOperands(aOperands, aTypes, aOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(bOperands, odsBuildableType0, bOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MapaOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getA(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getB(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getA().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MapaOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MatchSyncOp definitions //===----------------------------------------------------------------------===// namespace detail { MatchSyncOpGenericAdaptorBase::MatchSyncOpGenericAdaptorBase(MatchSyncOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::MatchSyncKind MatchSyncOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } } // namespace detail MatchSyncOpAdaptor::MatchSyncOpAdaptor(MatchSyncOp op) : MatchSyncOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MatchSyncOpAdaptor::verify(::mlir::Location loc) { auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'nvvm.match.sync' op requires attribute 'kind'"); if (tblgen_kind && !((::llvm::isa<::mlir::NVVM::MatchSyncKindAttr>(tblgen_kind)))) return emitError(loc, "'nvvm.match.sync' op attribute 'kind' failed to satisfy constraint: NVVM match sync kind"); return ::mlir::success(); } ::llvm::LogicalResult MatchSyncOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MatchSyncOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MatchSyncOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.kind.getAsOpaquePointer())); } std::optional MatchSyncOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "kind") return prop.kind; return std::nullopt; } void MatchSyncOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } } void MatchSyncOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.kind) attrs.append("kind", prop.kind); } ::llvm::LogicalResult MatchSyncOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps37(attr, "kind", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MatchSyncOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.kind))) return ::mlir::failure(); return ::mlir::success(); } void MatchSyncOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.kind); } ::mlir::NVVM::MatchSyncKind MatchSyncOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } void MatchSyncOp::setKind(::mlir::NVVM::MatchSyncKind attrValue) { getProperties().kind = ::mlir::NVVM::MatchSyncKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MatchSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKindAttr kind) { odsState.addOperands(thread_mask); odsState.addOperands(val); odsState.getOrAddProperties().kind = kind; odsState.addTypes(res); } MatchSyncOp MatchSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKindAttr kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(thread_mask), std::forward(val), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MatchSyncOp MatchSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKindAttr kind) { return create(builder, builder.getLoc(), std::forward(res), std::forward(thread_mask), std::forward(val), std::forward(kind)); } void MatchSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKindAttr kind) { odsState.addOperands(thread_mask); odsState.addOperands(val); odsState.getOrAddProperties().kind = kind; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MatchSyncOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MatchSyncOp MatchSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKindAttr kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(thread_mask), std::forward(val), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MatchSyncOp MatchSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKindAttr kind) { return create(builder, builder.getLoc(), std::forward(thread_mask), std::forward(val), std::forward(kind)); } void MatchSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKindAttr kind) { odsState.addOperands(thread_mask); odsState.addOperands(val); odsState.getOrAddProperties().kind = kind; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MatchSyncOp MatchSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKindAttr kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(thread_mask), std::forward(val), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MatchSyncOp MatchSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKindAttr kind) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(thread_mask), std::forward(val), std::forward(kind)); } void MatchSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKind kind) { odsState.addOperands(thread_mask); odsState.addOperands(val); odsState.getOrAddProperties().kind = ::mlir::NVVM::MatchSyncKindAttr::get(odsBuilder.getContext(), kind); odsState.addTypes(res); } MatchSyncOp MatchSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKind kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(thread_mask), std::forward(val), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MatchSyncOp MatchSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKind kind) { return create(builder, builder.getLoc(), std::forward(res), std::forward(thread_mask), std::forward(val), std::forward(kind)); } void MatchSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKind kind) { odsState.addOperands(thread_mask); odsState.addOperands(val); odsState.getOrAddProperties().kind = ::mlir::NVVM::MatchSyncKindAttr::get(odsBuilder.getContext(), kind); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MatchSyncOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MatchSyncOp MatchSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKind kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(thread_mask), std::forward(val), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MatchSyncOp MatchSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKind kind) { return create(builder, builder.getLoc(), std::forward(thread_mask), std::forward(val), std::forward(kind)); } void MatchSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKind kind) { odsState.addOperands(thread_mask); odsState.addOperands(val); odsState.getOrAddProperties().kind = ::mlir::NVVM::MatchSyncKindAttr::get(odsBuilder.getContext(), kind); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MatchSyncOp MatchSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKind kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(thread_mask), std::forward(val), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MatchSyncOp MatchSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::NVVM::MatchSyncKind kind) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(thread_mask), std::forward(val), std::forward(kind)); } void MatchSyncOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } MatchSyncOp MatchSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MatchSyncOp MatchSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MatchSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MatchSyncOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MatchSyncOp MatchSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MatchSyncOp MatchSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MatchSyncOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MatchSyncOp MatchSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MatchSyncOp MatchSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MatchSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MatchSyncOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MatchSyncOp MatchSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MatchSyncOp MatchSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult MatchSyncOp::verifyInvariantsImpl() { auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps37(*this, tblgen_kind, "kind"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps32(*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_NVVMOps33(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MatchSyncOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult MatchSyncOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::MatchSyncKindAttr kindAttr; ::mlir::OpAsmParser::UnresolvedOperand thread_maskRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> thread_maskOperands(&thread_maskRawOperand, 1); ::llvm::SMLoc thread_maskOperandsLoc; (void)thread_maskOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand valRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valOperands(&valRawOperand, 1); ::llvm::SMLoc valOperandsLoc; (void)valOperandsLoc; ::mlir::Type valRawType{}; ::llvm::ArrayRef<::mlir::Type> valTypes(&valRawType, 1); ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (parser.parseCustomAttributeWithFallback(kindAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (kindAttr) result.getOrAddProperties().kind = kindAttr; thread_maskOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(thread_maskRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); valOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(valRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); valRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); result.addTypes(resTypes); if (parser.resolveOperands(thread_maskOperands, odsBuildableType0, thread_maskOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(valOperands, valTypes, valOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MatchSyncOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getKindAttr()); _odsPrinter << ' '; _odsPrinter << getThreadMask(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getVal(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("kind"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getVal().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } ::llvm::LogicalResult MatchSyncOp::inferReturnTypes(::mlir::MLIRContext *context, std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { MatchSyncOp::Adaptor adaptor(operands, attributes, properties, regions); return MatchSyncOp::inferReturnTypes(context, location, adaptor, inferredReturnTypes); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MatchSyncOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::MatchSyncOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MembarOp definitions //===----------------------------------------------------------------------===// namespace detail { MembarOpGenericAdaptorBase::MembarOpGenericAdaptorBase(MembarOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::MemScopeKind MembarOpGenericAdaptorBase::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } } // namespace detail MembarOpAdaptor::MembarOpAdaptor(MembarOp op) : MembarOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MembarOpAdaptor::verify(::mlir::Location loc) { auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (!tblgen_scope) return emitError(loc, "'nvvm.memory.barrier' op requires attribute 'scope'"); if (tblgen_scope && !((::llvm::isa<::mlir::NVVM::MemScopeKindAttr>(tblgen_scope)))) return emitError(loc, "'nvvm.memory.barrier' op attribute 'scope' failed to satisfy constraint: NVVM Memory Scope kind"); return ::mlir::success(); } ::llvm::LogicalResult MembarOp::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.scope; auto attr = dict.get("scope"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scope` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MembarOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.scope; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("scope", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MembarOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.scope.getAsOpaquePointer())); } std::optional MembarOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "scope") return prop.scope; return std::nullopt; } void MembarOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "scope") { prop.scope = ::llvm::dyn_cast_or_null>(value); return; } } void MembarOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.scope) attrs.append("scope", prop.scope); } ::llvm::LogicalResult MembarOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getScopeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(attr, "scope", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MembarOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.scope))) return ::mlir::failure(); return ::mlir::success(); } void MembarOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.scope); } ::mlir::NVVM::MemScopeKind MembarOp::getScope() { auto attr = getScopeAttr(); return attr.getValue(); } void MembarOp::setScope(::mlir::NVVM::MemScopeKind attrValue) { getProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MembarOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::MemScopeKindAttr scope) { odsState.getOrAddProperties().scope = scope; } MembarOp MembarOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::MemScopeKindAttr scope) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(scope)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MembarOp MembarOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::MemScopeKindAttr scope) { return create(builder, builder.getLoc(), std::forward(scope)); } void MembarOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKindAttr scope) { odsState.getOrAddProperties().scope = scope; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } MembarOp MembarOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKindAttr scope) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(scope)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MembarOp MembarOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKindAttr scope) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(scope)); } void MembarOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::MemScopeKind scope) { odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); } MembarOp MembarOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::MemScopeKind scope) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(scope)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MembarOp MembarOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::MemScopeKind scope) { return create(builder, builder.getLoc(), std::forward(scope)); } void MembarOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKind scope) { odsState.getOrAddProperties().scope = ::mlir::NVVM::MemScopeKindAttr::get(odsBuilder.getContext(), scope); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } MembarOp MembarOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKind scope) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(scope)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MembarOp MembarOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MemScopeKind scope) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(scope)); } void MembarOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } MembarOp MembarOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MembarOp MembarOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MembarOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MembarOp MembarOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MembarOp MembarOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult MembarOp::verifyInvariantsImpl() { auto tblgen_scope = getProperties().scope; (void)tblgen_scope; if (!tblgen_scope) return emitOpError("requires attribute 'scope'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps27(*this, tblgen_scope, "scope"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult MembarOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult MembarOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::MemScopeKindAttr scopeAttr; if (parser.parseCustomAttributeWithFallback(scopeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (scopeAttr) result.getOrAddProperties().scope = scopeAttr; { 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 MembarOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getScopeAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("scope"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MembarOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::MembarOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MmaBlockScaleOp definitions //===----------------------------------------------------------------------===// namespace detail { MmaBlockScaleOpGenericAdaptorBase::MmaBlockScaleOpGenericAdaptorBase(MmaBlockScaleOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair MmaBlockScaleOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::NVVM::MMAShapeAttr MmaBlockScaleOpGenericAdaptorBase::getShape() { auto attr = getShapeAttr(); return ::llvm::cast<::mlir::NVVM::MMAShapeAttr>(attr); } ::std::optional<::mlir::NVVM::MMATypes> MmaBlockScaleOpGenericAdaptorBase::getMultiplicandAPtxType() { auto attr = getMultiplicandAPtxTypeAttr(); return attr ? ::std::optional<::mlir::NVVM::MMATypes>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::NVVM::MMATypes> MmaBlockScaleOpGenericAdaptorBase::getMultiplicandBPtxType() { auto attr = getMultiplicandBPtxTypeAttr(); return attr ? ::std::optional<::mlir::NVVM::MMATypes>(attr.getValue()) : (::std::nullopt); } ::mlir::NVVM::ScaleVecSize MmaBlockScaleOpGenericAdaptorBase::getScaleVecSize() { auto attr = getScaleVecSizeAttr(); return attr.getValue(); } ::mlir::NVVM::BlockScaleFormat MmaBlockScaleOpGenericAdaptorBase::getBlockScaleFormat() { auto attr = getBlockScaleFormatAttr(); return attr.getValue(); } ::mlir::NVVM::MMABlockScaleKind MmaBlockScaleOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } } // namespace detail MmaBlockScaleOpAdaptor::MmaBlockScaleOpAdaptor(MmaBlockScaleOp op) : MmaBlockScaleOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MmaBlockScaleOpAdaptor::verify(::mlir::Location loc) { auto tblgen_blockScaleFormat = getProperties().blockScaleFormat; (void)tblgen_blockScaleFormat; if (!tblgen_blockScaleFormat) return emitError(loc, "'nvvm.mma.block_scale' op requires attribute 'blockScaleFormat'"); auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'nvvm.mma.block_scale' op requires attribute 'kind'"); auto tblgen_multiplicandAPtxType = getProperties().multiplicandAPtxType; (void)tblgen_multiplicandAPtxType; auto tblgen_multiplicandBPtxType = getProperties().multiplicandBPtxType; (void)tblgen_multiplicandBPtxType; auto tblgen_scaleVecSize = getProperties().scaleVecSize; (void)tblgen_scaleVecSize; if (!tblgen_scaleVecSize) return emitError(loc, "'nvvm.mma.block_scale' op requires attribute 'scaleVecSize'"); auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitError(loc, "'nvvm.mma.block_scale' op requires attribute 'shape'"); if (tblgen_shape && !((::llvm::isa<::mlir::NVVM::MMAShapeAttr>(tblgen_shape)))) return emitError(loc, "'nvvm.mma.block_scale' op attribute 'shape' failed to satisfy constraint: Attribute for MMA operation shape."); if (tblgen_multiplicandAPtxType && !((::llvm::isa<::mlir::NVVM::MMATypesAttr>(tblgen_multiplicandAPtxType)))) return emitError(loc, "'nvvm.mma.block_scale' op attribute 'multiplicandAPtxType' failed to satisfy constraint: NVVM MMA types"); if (tblgen_multiplicandBPtxType && !((::llvm::isa<::mlir::NVVM::MMATypesAttr>(tblgen_multiplicandBPtxType)))) return emitError(loc, "'nvvm.mma.block_scale' op attribute 'multiplicandBPtxType' failed to satisfy constraint: NVVM MMA types"); if (tblgen_scaleVecSize && !((::llvm::isa<::mlir::NVVM::ScaleVecSizeAttr>(tblgen_scaleVecSize)))) return emitError(loc, "'nvvm.mma.block_scale' op attribute 'scaleVecSize' failed to satisfy constraint: MMA Scale Vector Sizes"); if (tblgen_blockScaleFormat && !((::llvm::isa<::mlir::NVVM::BlockScaleFormatAttr>(tblgen_blockScaleFormat)))) return emitError(loc, "'nvvm.mma.block_scale' op attribute 'blockScaleFormat' failed to satisfy constraint: MMA Block Scale Format"); if (tblgen_kind && !((::llvm::isa<::mlir::NVVM::MMABlockScaleKindAttr>(tblgen_kind)))) return emitError(loc, "'nvvm.mma.block_scale' op attribute 'kind' failed to satisfy constraint: Block Scale Kind"); return ::mlir::success(); } std::pair MmaBlockScaleOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange MmaBlockScaleOp::getOperandAMutable() { 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 MmaBlockScaleOp::getOperandBMutable() { 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 MmaBlockScaleOp::getOperandCMutable() { 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 MmaBlockScaleOp::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.blockScaleFormat; auto attr = dict.get("blockScaleFormat"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `blockScaleFormat` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multiplicandAPtxType; auto attr = dict.get("multiplicandAPtxType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multiplicandAPtxType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multiplicandBPtxType; auto attr = dict.get("multiplicandBPtxType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multiplicandBPtxType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.scaleVecSize; auto attr = dict.get("scaleVecSize"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scaleVecSize` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.shape; auto attr = dict.get("shape"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `shape` 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 MmaBlockScaleOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.blockScaleFormat; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("blockScaleFormat", propStorage)); } { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", propStorage)); } { const auto &propStorage = prop.multiplicandAPtxType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("multiplicandAPtxType", propStorage)); } { const auto &propStorage = prop.multiplicandBPtxType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("multiplicandBPtxType", propStorage)); } { const auto &propStorage = prop.scaleVecSize; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("scaleVecSize", propStorage)); } { const auto &propStorage = prop.shape; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("shape", 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 MmaBlockScaleOp::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.blockScaleFormat.getAsOpaquePointer()), llvm::hash_value(prop.kind.getAsOpaquePointer()), llvm::hash_value(prop.multiplicandAPtxType.getAsOpaquePointer()), llvm::hash_value(prop.multiplicandBPtxType.getAsOpaquePointer()), llvm::hash_value(prop.scaleVecSize.getAsOpaquePointer()), llvm::hash_value(prop.shape.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional MmaBlockScaleOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "blockScaleFormat") return prop.blockScaleFormat; if (name == "kind") return prop.kind; if (name == "multiplicandAPtxType") return prop.multiplicandAPtxType; if (name == "multiplicandBPtxType") return prop.multiplicandBPtxType; if (name == "scaleVecSize") return prop.scaleVecSize; if (name == "shape") return prop.shape; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void MmaBlockScaleOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "blockScaleFormat") { prop.blockScaleFormat = ::llvm::dyn_cast_or_null>(value); return; } if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } if (name == "multiplicandAPtxType") { prop.multiplicandAPtxType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "multiplicandBPtxType") { prop.multiplicandBPtxType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "scaleVecSize") { prop.scaleVecSize = ::llvm::dyn_cast_or_null>(value); return; } if (name == "shape") { prop.shape = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void MmaBlockScaleOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.blockScaleFormat) attrs.append("blockScaleFormat", prop.blockScaleFormat); if (prop.kind) attrs.append("kind", prop.kind); if (prop.multiplicandAPtxType) attrs.append("multiplicandAPtxType", prop.multiplicandAPtxType); if (prop.multiplicandBPtxType) attrs.append("multiplicandBPtxType", prop.multiplicandBPtxType); if (prop.scaleVecSize) attrs.append("scaleVecSize", prop.scaleVecSize); if (prop.shape) attrs.append("shape", prop.shape); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult MmaBlockScaleOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getBlockScaleFormatAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps41(attr, "blockScaleFormat", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps42(attr, "kind", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getMultiplicandAPtxTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(attr, "multiplicandAPtxType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getMultiplicandBPtxTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(attr, "multiplicandBPtxType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getScaleVecSizeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps40(attr, "scaleVecSize", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getShapeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps38(attr, "shape", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MmaBlockScaleOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.blockScaleFormat))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.kind))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.multiplicandAPtxType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.multiplicandBPtxType))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readAttribute(prop.scaleVecSize))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.shape))) 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 MmaBlockScaleOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.blockScaleFormat); writer.writeAttribute(prop.kind); writer.writeOptionalAttribute(prop.multiplicandAPtxType); writer.writeOptionalAttribute(prop.multiplicandBPtxType); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeAttribute(prop.scaleVecSize); writer.writeAttribute(prop.shape); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::NVVM::MMAShapeAttr MmaBlockScaleOp::getShape() { auto attr = getShapeAttr(); return ::llvm::cast<::mlir::NVVM::MMAShapeAttr>(attr); } ::std::optional<::mlir::NVVM::MMATypes> MmaBlockScaleOp::getMultiplicandAPtxType() { auto attr = getMultiplicandAPtxTypeAttr(); return attr ? ::std::optional<::mlir::NVVM::MMATypes>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::NVVM::MMATypes> MmaBlockScaleOp::getMultiplicandBPtxType() { auto attr = getMultiplicandBPtxTypeAttr(); return attr ? ::std::optional<::mlir::NVVM::MMATypes>(attr.getValue()) : (::std::nullopt); } ::mlir::NVVM::ScaleVecSize MmaBlockScaleOp::getScaleVecSize() { auto attr = getScaleVecSizeAttr(); return attr.getValue(); } ::mlir::NVVM::BlockScaleFormat MmaBlockScaleOp::getBlockScaleFormat() { auto attr = getBlockScaleFormatAttr(); return attr.getValue(); } ::mlir::NVVM::MMABlockScaleKind MmaBlockScaleOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } void MmaBlockScaleOp::setMultiplicandAPtxType(::std::optional<::mlir::NVVM::MMATypes> attrValue) { auto &odsProp = getProperties().multiplicandAPtxType; if (attrValue) odsProp = ::mlir::NVVM::MMATypesAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void MmaBlockScaleOp::setMultiplicandBPtxType(::std::optional<::mlir::NVVM::MMATypes> attrValue) { auto &odsProp = getProperties().multiplicandBPtxType; if (attrValue) odsProp = ::mlir::NVVM::MMATypesAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void MmaBlockScaleOp::setScaleVecSize(::mlir::NVVM::ScaleVecSize attrValue) { getProperties().scaleVecSize = ::mlir::NVVM::ScaleVecSizeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MmaBlockScaleOp::setBlockScaleFormat(::mlir::NVVM::BlockScaleFormat attrValue) { getProperties().blockScaleFormat = ::mlir::NVVM::BlockScaleFormatAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MmaBlockScaleOp::setKind(::mlir::NVVM::MMABlockScaleKind attrValue) { getProperties().kind = ::mlir::NVVM::MMABlockScaleKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } MmaBlockScaleOp MmaBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType, ValueRange operandA, ValueRange operandB, ValueRange operandC, Value scaleAData, Value byteIdA, Value threadIdA, Value scaleBData, Value byteIdB, Value threadIdB, ArrayRef shape, std::optional> multiplicandPtxTypes, ScaleVecSize scaleVecSize, BlockScaleFormat blockScaleFormat, MMABlockScaleKind kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB), std::forward(shape), std::forward(multiplicandPtxTypes), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaBlockScaleOp MmaBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType, ValueRange operandA, ValueRange operandB, ValueRange operandC, Value scaleAData, Value byteIdA, Value threadIdA, Value scaleBData, Value byteIdB, Value threadIdB, ArrayRef shape, std::optional> multiplicandPtxTypes, ScaleVecSize scaleVecSize, BlockScaleFormat blockScaleFormat, MMABlockScaleKind kind) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB), std::forward(shape), std::forward(multiplicandPtxTypes), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind)); } void MmaBlockScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSizeAttr scaleVecSize, ::mlir::NVVM::BlockScaleFormatAttr blockScaleFormat, ::mlir::NVVM::MMABlockScaleKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { odsState.addOperands(operandA); odsState.addOperands(operandB); odsState.addOperands(operandC); odsState.addOperands(scaleAData); odsState.addOperands(byteIdA); odsState.addOperands(threadIdA); odsState.addOperands(scaleBData); odsState.addOperands(byteIdB); odsState.addOperands(threadIdB); ::llvm::copy(::llvm::ArrayRef({static_cast(operandA.size()), static_cast(operandB.size()), static_cast(operandC.size()), 1, 1, 1, 1, 1, 1}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().shape = shape; if (multiplicandAPtxType) { odsState.getOrAddProperties().multiplicandAPtxType = multiplicandAPtxType; } if (multiplicandBPtxType) { odsState.getOrAddProperties().multiplicandBPtxType = multiplicandBPtxType; } odsState.getOrAddProperties().scaleVecSize = scaleVecSize; odsState.getOrAddProperties().blockScaleFormat = blockScaleFormat; odsState.getOrAddProperties().kind = kind; odsState.addTypes(res); } MmaBlockScaleOp MmaBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSizeAttr scaleVecSize, ::mlir::NVVM::BlockScaleFormatAttr blockScaleFormat, ::mlir::NVVM::MMABlockScaleKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(shape), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaBlockScaleOp MmaBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSizeAttr scaleVecSize, ::mlir::NVVM::BlockScaleFormatAttr blockScaleFormat, ::mlir::NVVM::MMABlockScaleKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { return create(builder, builder.getLoc(), std::forward(res), std::forward(shape), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB)); } void MmaBlockScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSizeAttr scaleVecSize, ::mlir::NVVM::BlockScaleFormatAttr blockScaleFormat, ::mlir::NVVM::MMABlockScaleKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { odsState.addOperands(operandA); odsState.addOperands(operandB); odsState.addOperands(operandC); odsState.addOperands(scaleAData); odsState.addOperands(byteIdA); odsState.addOperands(threadIdA); odsState.addOperands(scaleBData); odsState.addOperands(byteIdB); odsState.addOperands(threadIdB); ::llvm::copy(::llvm::ArrayRef({static_cast(operandA.size()), static_cast(operandB.size()), static_cast(operandC.size()), 1, 1, 1, 1, 1, 1}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().shape = shape; if (multiplicandAPtxType) { odsState.getOrAddProperties().multiplicandAPtxType = multiplicandAPtxType; } if (multiplicandBPtxType) { odsState.getOrAddProperties().multiplicandBPtxType = multiplicandBPtxType; } odsState.getOrAddProperties().scaleVecSize = scaleVecSize; odsState.getOrAddProperties().blockScaleFormat = blockScaleFormat; odsState.getOrAddProperties().kind = kind; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MmaBlockScaleOp MmaBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSizeAttr scaleVecSize, ::mlir::NVVM::BlockScaleFormatAttr blockScaleFormat, ::mlir::NVVM::MMABlockScaleKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(shape), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaBlockScaleOp MmaBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSizeAttr scaleVecSize, ::mlir::NVVM::BlockScaleFormatAttr blockScaleFormat, ::mlir::NVVM::MMABlockScaleKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(shape), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB)); } void MmaBlockScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSize scaleVecSize, ::mlir::NVVM::BlockScaleFormat blockScaleFormat, ::mlir::NVVM::MMABlockScaleKind kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { odsState.addOperands(operandA); odsState.addOperands(operandB); odsState.addOperands(operandC); odsState.addOperands(scaleAData); odsState.addOperands(byteIdA); odsState.addOperands(threadIdA); odsState.addOperands(scaleBData); odsState.addOperands(byteIdB); odsState.addOperands(threadIdB); ::llvm::copy(::llvm::ArrayRef({static_cast(operandA.size()), static_cast(operandB.size()), static_cast(operandC.size()), 1, 1, 1, 1, 1, 1}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().shape = shape; if (multiplicandAPtxType) { odsState.getOrAddProperties().multiplicandAPtxType = multiplicandAPtxType; } if (multiplicandBPtxType) { odsState.getOrAddProperties().multiplicandBPtxType = multiplicandBPtxType; } odsState.getOrAddProperties().scaleVecSize = ::mlir::NVVM::ScaleVecSizeAttr::get(odsBuilder.getContext(), scaleVecSize); odsState.getOrAddProperties().blockScaleFormat = ::mlir::NVVM::BlockScaleFormatAttr::get(odsBuilder.getContext(), blockScaleFormat); odsState.getOrAddProperties().kind = ::mlir::NVVM::MMABlockScaleKindAttr::get(odsBuilder.getContext(), kind); odsState.addTypes(res); } MmaBlockScaleOp MmaBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSize scaleVecSize, ::mlir::NVVM::BlockScaleFormat blockScaleFormat, ::mlir::NVVM::MMABlockScaleKind kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(shape), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaBlockScaleOp MmaBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSize scaleVecSize, ::mlir::NVVM::BlockScaleFormat blockScaleFormat, ::mlir::NVVM::MMABlockScaleKind kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { return create(builder, builder.getLoc(), std::forward(res), std::forward(shape), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB)); } void MmaBlockScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSize scaleVecSize, ::mlir::NVVM::BlockScaleFormat blockScaleFormat, ::mlir::NVVM::MMABlockScaleKind kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { odsState.addOperands(operandA); odsState.addOperands(operandB); odsState.addOperands(operandC); odsState.addOperands(scaleAData); odsState.addOperands(byteIdA); odsState.addOperands(threadIdA); odsState.addOperands(scaleBData); odsState.addOperands(byteIdB); odsState.addOperands(threadIdB); ::llvm::copy(::llvm::ArrayRef({static_cast(operandA.size()), static_cast(operandB.size()), static_cast(operandC.size()), 1, 1, 1, 1, 1, 1}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().shape = shape; if (multiplicandAPtxType) { odsState.getOrAddProperties().multiplicandAPtxType = multiplicandAPtxType; } if (multiplicandBPtxType) { odsState.getOrAddProperties().multiplicandBPtxType = multiplicandBPtxType; } odsState.getOrAddProperties().scaleVecSize = ::mlir::NVVM::ScaleVecSizeAttr::get(odsBuilder.getContext(), scaleVecSize); odsState.getOrAddProperties().blockScaleFormat = ::mlir::NVVM::BlockScaleFormatAttr::get(odsBuilder.getContext(), blockScaleFormat); odsState.getOrAddProperties().kind = ::mlir::NVVM::MMABlockScaleKindAttr::get(odsBuilder.getContext(), kind); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MmaBlockScaleOp MmaBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSize scaleVecSize, ::mlir::NVVM::BlockScaleFormat blockScaleFormat, ::mlir::NVVM::MMABlockScaleKind kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(shape), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaBlockScaleOp MmaBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSize scaleVecSize, ::mlir::NVVM::BlockScaleFormat blockScaleFormat, ::mlir::NVVM::MMABlockScaleKind kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(shape), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB)); } void MmaBlockScaleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 6u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } MmaBlockScaleOp MmaBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaBlockScaleOp MmaBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MmaBlockScaleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 6u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MmaBlockScaleOp MmaBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaBlockScaleOp MmaBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult MmaBlockScaleOp::verifyInvariantsImpl() { auto tblgen_blockScaleFormat = getProperties().blockScaleFormat; (void)tblgen_blockScaleFormat; if (!tblgen_blockScaleFormat) return emitOpError("requires attribute 'blockScaleFormat'"); auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); auto tblgen_multiplicandAPtxType = getProperties().multiplicandAPtxType; (void)tblgen_multiplicandAPtxType; auto tblgen_multiplicandBPtxType = getProperties().multiplicandBPtxType; (void)tblgen_multiplicandBPtxType; auto tblgen_scaleVecSize = getProperties().scaleVecSize; (void)tblgen_scaleVecSize; if (!tblgen_scaleVecSize) return emitOpError("requires attribute 'scaleVecSize'"); auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitOpError("requires attribute 'shape'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps38(*this, tblgen_shape, "shape"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(*this, tblgen_multiplicandAPtxType, "multiplicandAPtxType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(*this, tblgen_multiplicandBPtxType, "multiplicandBPtxType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps40(*this, tblgen_scaleVecSize, "scaleVecSize"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps41(*this, tblgen_blockScaleFormat, "blockScaleFormat"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps42(*this, tblgen_kind, "kind"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps34(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps34(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps34(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup5 = getODSOperands(5); for (auto v : valueGroup5) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup6 = getODSOperands(6); for (auto v : valueGroup6) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup7 = getODSOperands(7); for (auto v : valueGroup7) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup8 = getODSOperands(8); for (auto v : valueGroup8) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps11(*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_NVVMOps35(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MmaBlockScaleOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult MmaBlockScaleOp::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.shape; auto shapeAttrName = ::mlir::StringAttr::get(ctx, "shape"); auto attr = dict.get(shapeAttrName); usedKeys.insert(shapeAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for shape in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `shape` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multiplicandAPtxType; auto multiplicandAPtxTypeAttrName = ::mlir::StringAttr::get(ctx, "multiplicandAPtxType"); auto attr = dict.get(multiplicandAPtxTypeAttrName); usedKeys.insert(multiplicandAPtxTypeAttrName); if (attr || /*isRequired=*/false) { if (!attr) { emitError() << "expected key entry for multiplicandAPtxType in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multiplicandAPtxType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multiplicandBPtxType; auto multiplicandBPtxTypeAttrName = ::mlir::StringAttr::get(ctx, "multiplicandBPtxType"); auto attr = dict.get(multiplicandBPtxTypeAttrName); usedKeys.insert(multiplicandBPtxTypeAttrName); if (attr || /*isRequired=*/false) { if (!attr) { emitError() << "expected key entry for multiplicandBPtxType in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multiplicandBPtxType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.scaleVecSize; auto scaleVecSizeAttrName = ::mlir::StringAttr::get(ctx, "scaleVecSize"); auto attr = dict.get(scaleVecSizeAttrName); usedKeys.insert(scaleVecSizeAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for scaleVecSize in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scaleVecSize` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.blockScaleFormat; auto blockScaleFormatAttrName = ::mlir::StringAttr::get(ctx, "blockScaleFormat"); auto attr = dict.get(blockScaleFormatAttrName); usedKeys.insert(blockScaleFormatAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for blockScaleFormat in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `blockScaleFormat` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.kind; auto kindAttrName = ::mlir::StringAttr::get(ctx, "kind"); auto attr = dict.get(kindAttrName); usedKeys.insert(kindAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for kind in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` 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::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MmaBlockScaleOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::MmaBlockScaleOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MmaOp definitions //===----------------------------------------------------------------------===// namespace detail { MmaOpGenericAdaptorBase::MmaOpGenericAdaptorBase(MmaOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair MmaOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::NVVM::MMAShapeAttr MmaOpGenericAdaptorBase::getShape() { auto attr = getShapeAttr(); return ::llvm::cast<::mlir::NVVM::MMAShapeAttr>(attr); } ::std::optional<::mlir::NVVM::MMAB1Op> MmaOpGenericAdaptorBase::getB1Op() { auto attr = getB1OpAttr(); return attr ? ::std::optional<::mlir::NVVM::MMAB1Op>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::NVVM::MMAIntOverflow> MmaOpGenericAdaptorBase::getIntOverflowBehavior() { auto attr = getIntOverflowBehaviorAttr(); return attr ? ::std::optional<::mlir::NVVM::MMAIntOverflow>(attr.getValue()) : (::std::nullopt); } ::mlir::NVVM::MMALayout MmaOpGenericAdaptorBase::getLayoutA() { auto attr = getLayoutAAttr(); return attr.getValue(); } ::mlir::NVVM::MMALayout MmaOpGenericAdaptorBase::getLayoutB() { auto attr = getLayoutBAttr(); return attr.getValue(); } ::std::optional<::mlir::NVVM::MMATypes> MmaOpGenericAdaptorBase::getMultiplicandAPtxType() { auto attr = getMultiplicandAPtxTypeAttr(); return attr ? ::std::optional<::mlir::NVVM::MMATypes>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::NVVM::MMATypes> MmaOpGenericAdaptorBase::getMultiplicandBPtxType() { auto attr = getMultiplicandBPtxTypeAttr(); return attr ? ::std::optional<::mlir::NVVM::MMATypes>(attr.getValue()) : (::std::nullopt); } } // namespace detail MmaOpAdaptor::MmaOpAdaptor(MmaOp op) : MmaOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MmaOpAdaptor::verify(::mlir::Location loc) { auto tblgen_b1Op = getProperties().b1Op; (void)tblgen_b1Op; auto tblgen_intOverflowBehavior = getProperties().intOverflowBehavior; (void)tblgen_intOverflowBehavior; auto tblgen_layoutA = getProperties().layoutA; (void)tblgen_layoutA; if (!tblgen_layoutA) return emitError(loc, "'nvvm.mma.sync' op requires attribute 'layoutA'"); auto tblgen_layoutB = getProperties().layoutB; (void)tblgen_layoutB; if (!tblgen_layoutB) return emitError(loc, "'nvvm.mma.sync' op requires attribute 'layoutB'"); auto tblgen_multiplicandAPtxType = getProperties().multiplicandAPtxType; (void)tblgen_multiplicandAPtxType; auto tblgen_multiplicandBPtxType = getProperties().multiplicandBPtxType; (void)tblgen_multiplicandBPtxType; auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitError(loc, "'nvvm.mma.sync' op requires attribute 'shape'"); if (tblgen_shape && !((::llvm::isa<::mlir::NVVM::MMAShapeAttr>(tblgen_shape)))) return emitError(loc, "'nvvm.mma.sync' op attribute 'shape' failed to satisfy constraint: Attribute for MMA operation shape."); if (tblgen_b1Op && !((::llvm::isa<::mlir::NVVM::MMAB1OpAttr>(tblgen_b1Op)))) return emitError(loc, "'nvvm.mma.sync' op attribute 'b1Op' failed to satisfy constraint: MMA binary operations"); if (tblgen_intOverflowBehavior && !((::llvm::isa<::mlir::NVVM::MMAIntOverflowAttr>(tblgen_intOverflowBehavior)))) return emitError(loc, "'nvvm.mma.sync' op attribute 'intOverflowBehavior' failed to satisfy constraint: MMA overflow options"); if (tblgen_layoutA && !((::llvm::isa<::mlir::NVVM::MMALayoutAttr>(tblgen_layoutA)))) return emitError(loc, "'nvvm.mma.sync' op attribute 'layoutA' failed to satisfy constraint: NVVM MMA layout"); if (tblgen_layoutB && !((::llvm::isa<::mlir::NVVM::MMALayoutAttr>(tblgen_layoutB)))) return emitError(loc, "'nvvm.mma.sync' op attribute 'layoutB' failed to satisfy constraint: NVVM MMA layout"); if (tblgen_multiplicandAPtxType && !((::llvm::isa<::mlir::NVVM::MMATypesAttr>(tblgen_multiplicandAPtxType)))) return emitError(loc, "'nvvm.mma.sync' op attribute 'multiplicandAPtxType' failed to satisfy constraint: NVVM MMA types"); if (tblgen_multiplicandBPtxType && !((::llvm::isa<::mlir::NVVM::MMATypesAttr>(tblgen_multiplicandBPtxType)))) return emitError(loc, "'nvvm.mma.sync' op attribute 'multiplicandBPtxType' failed to satisfy constraint: NVVM MMA types"); return ::mlir::success(); } std::pair MmaOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange MmaOp::getOperandAMutable() { 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 MmaOp::getOperandBMutable() { 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 MmaOp::getOperandCMutable() { 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 MmaOp::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.b1Op; auto attr = dict.get("b1Op"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `b1Op` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.intOverflowBehavior; auto attr = dict.get("intOverflowBehavior"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `intOverflowBehavior` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.layoutA; auto attr = dict.get("layoutA"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `layoutA` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.layoutB; auto attr = dict.get("layoutB"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `layoutB` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multiplicandAPtxType; auto attr = dict.get("multiplicandAPtxType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multiplicandAPtxType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multiplicandBPtxType; auto attr = dict.get("multiplicandBPtxType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multiplicandBPtxType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.shape; auto attr = dict.get("shape"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `shape` 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 MmaOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.b1Op; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("b1Op", propStorage)); } { const auto &propStorage = prop.intOverflowBehavior; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("intOverflowBehavior", propStorage)); } { const auto &propStorage = prop.layoutA; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("layoutA", propStorage)); } { const auto &propStorage = prop.layoutB; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("layoutB", propStorage)); } { const auto &propStorage = prop.multiplicandAPtxType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("multiplicandAPtxType", propStorage)); } { const auto &propStorage = prop.multiplicandBPtxType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("multiplicandBPtxType", propStorage)); } { const auto &propStorage = prop.shape; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("shape", 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 MmaOp::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.b1Op.getAsOpaquePointer()), llvm::hash_value(prop.intOverflowBehavior.getAsOpaquePointer()), llvm::hash_value(prop.layoutA.getAsOpaquePointer()), llvm::hash_value(prop.layoutB.getAsOpaquePointer()), llvm::hash_value(prop.multiplicandAPtxType.getAsOpaquePointer()), llvm::hash_value(prop.multiplicandBPtxType.getAsOpaquePointer()), llvm::hash_value(prop.shape.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional MmaOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "b1Op") return prop.b1Op; if (name == "intOverflowBehavior") return prop.intOverflowBehavior; if (name == "layoutA") return prop.layoutA; if (name == "layoutB") return prop.layoutB; if (name == "multiplicandAPtxType") return prop.multiplicandAPtxType; if (name == "multiplicandBPtxType") return prop.multiplicandBPtxType; if (name == "shape") return prop.shape; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void MmaOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "b1Op") { prop.b1Op = ::llvm::dyn_cast_or_null>(value); return; } if (name == "intOverflowBehavior") { prop.intOverflowBehavior = ::llvm::dyn_cast_or_null>(value); return; } if (name == "layoutA") { prop.layoutA = ::llvm::dyn_cast_or_null>(value); return; } if (name == "layoutB") { prop.layoutB = ::llvm::dyn_cast_or_null>(value); return; } if (name == "multiplicandAPtxType") { prop.multiplicandAPtxType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "multiplicandBPtxType") { prop.multiplicandBPtxType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "shape") { prop.shape = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void MmaOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.b1Op) attrs.append("b1Op", prop.b1Op); if (prop.intOverflowBehavior) attrs.append("intOverflowBehavior", prop.intOverflowBehavior); if (prop.layoutA) attrs.append("layoutA", prop.layoutA); if (prop.layoutB) attrs.append("layoutB", prop.layoutB); if (prop.multiplicandAPtxType) attrs.append("multiplicandAPtxType", prop.multiplicandAPtxType); if (prop.multiplicandBPtxType) attrs.append("multiplicandBPtxType", prop.multiplicandBPtxType); if (prop.shape) attrs.append("shape", prop.shape); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult MmaOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getB1OpAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps43(attr, "b1Op", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getIntOverflowBehaviorAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps44(attr, "intOverflowBehavior", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getLayoutAAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(attr, "layoutA", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getLayoutBAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(attr, "layoutB", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getMultiplicandAPtxTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(attr, "multiplicandAPtxType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getMultiplicandBPtxTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(attr, "multiplicandBPtxType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getShapeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps38(attr, "shape", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MmaOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.b1Op))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.intOverflowBehavior))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.layoutA))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.layoutB))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.multiplicandAPtxType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.multiplicandBPtxType))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readAttribute(prop.shape))) 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 MmaOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.b1Op); writer.writeOptionalAttribute(prop.intOverflowBehavior); writer.writeAttribute(prop.layoutA); writer.writeAttribute(prop.layoutB); writer.writeOptionalAttribute(prop.multiplicandAPtxType); writer.writeOptionalAttribute(prop.multiplicandBPtxType); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeAttribute(prop.shape); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::NVVM::MMAShapeAttr MmaOp::getShape() { auto attr = getShapeAttr(); return ::llvm::cast<::mlir::NVVM::MMAShapeAttr>(attr); } ::std::optional<::mlir::NVVM::MMAB1Op> MmaOp::getB1Op() { auto attr = getB1OpAttr(); return attr ? ::std::optional<::mlir::NVVM::MMAB1Op>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::NVVM::MMAIntOverflow> MmaOp::getIntOverflowBehavior() { auto attr = getIntOverflowBehaviorAttr(); return attr ? ::std::optional<::mlir::NVVM::MMAIntOverflow>(attr.getValue()) : (::std::nullopt); } ::mlir::NVVM::MMALayout MmaOp::getLayoutA() { auto attr = getLayoutAAttr(); return attr.getValue(); } ::mlir::NVVM::MMALayout MmaOp::getLayoutB() { auto attr = getLayoutBAttr(); return attr.getValue(); } ::std::optional<::mlir::NVVM::MMATypes> MmaOp::getMultiplicandAPtxType() { auto attr = getMultiplicandAPtxTypeAttr(); return attr ? ::std::optional<::mlir::NVVM::MMATypes>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::NVVM::MMATypes> MmaOp::getMultiplicandBPtxType() { auto attr = getMultiplicandBPtxTypeAttr(); return attr ? ::std::optional<::mlir::NVVM::MMATypes>(attr.getValue()) : (::std::nullopt); } void MmaOp::setB1Op(::std::optional<::mlir::NVVM::MMAB1Op> attrValue) { auto &odsProp = getProperties().b1Op; if (attrValue) odsProp = ::mlir::NVVM::MMAB1OpAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void MmaOp::setIntOverflowBehavior(::std::optional<::mlir::NVVM::MMAIntOverflow> attrValue) { auto &odsProp = getProperties().intOverflowBehavior; if (attrValue) odsProp = ::mlir::NVVM::MMAIntOverflowAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void MmaOp::setLayoutA(::mlir::NVVM::MMALayout attrValue) { getProperties().layoutA = ::mlir::NVVM::MMALayoutAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MmaOp::setLayoutB(::mlir::NVVM::MMALayout attrValue) { getProperties().layoutB = ::mlir::NVVM::MMALayoutAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MmaOp::setMultiplicandAPtxType(::std::optional<::mlir::NVVM::MMATypes> attrValue) { auto &odsProp = getProperties().multiplicandAPtxType; if (attrValue) odsProp = ::mlir::NVVM::MMATypesAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void MmaOp::setMultiplicandBPtxType(::std::optional<::mlir::NVVM::MMATypes> attrValue) { auto &odsProp = getProperties().multiplicandBPtxType; if (attrValue) odsProp = ::mlir::NVVM::MMATypesAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } MmaOp MmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType, ValueRange operandA, ValueRange operandB, ValueRange operandC, ArrayRef shape, std::optional b1Op, std::optional intOverflow, std::optional> multiplicandPtxTypes, std::optional> multiplicandLayouts) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(shape), std::forward(b1Op), std::forward(intOverflow), std::forward(multiplicandPtxTypes), std::forward(multiplicandLayouts)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaOp MmaOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType, ValueRange operandA, ValueRange operandB, ValueRange operandC, ArrayRef shape, std::optional b1Op, std::optional intOverflow, std::optional> multiplicandPtxTypes, std::optional> multiplicandLayouts) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(shape), std::forward(b1Op), std::forward(intOverflow), std::forward(multiplicandPtxTypes), std::forward(multiplicandLayouts)); } void MmaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAB1OpAttr b1Op, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC) { odsState.addOperands(operandA); odsState.addOperands(operandB); odsState.addOperands(operandC); ::llvm::copy(::llvm::ArrayRef({static_cast(operandA.size()), static_cast(operandB.size()), static_cast(operandC.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().shape = shape; if (b1Op) { odsState.getOrAddProperties().b1Op = b1Op; } if (intOverflowBehavior) { odsState.getOrAddProperties().intOverflowBehavior = intOverflowBehavior; } odsState.getOrAddProperties().layoutA = layoutA; odsState.getOrAddProperties().layoutB = layoutB; if (multiplicandAPtxType) { odsState.getOrAddProperties().multiplicandAPtxType = multiplicandAPtxType; } if (multiplicandBPtxType) { odsState.getOrAddProperties().multiplicandBPtxType = multiplicandBPtxType; } odsState.addTypes(res); } MmaOp MmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAB1OpAttr b1Op, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(shape), std::forward(b1Op), std::forward(intOverflowBehavior), std::forward(layoutA), std::forward(layoutB), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(operandA), std::forward(operandB), std::forward(operandC)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaOp MmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAB1OpAttr b1Op, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC) { return create(builder, builder.getLoc(), std::forward(res), std::forward(shape), std::forward(b1Op), std::forward(intOverflowBehavior), std::forward(layoutA), std::forward(layoutB), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(operandA), std::forward(operandB), std::forward(operandC)); } void MmaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAB1OpAttr b1Op, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC) { odsState.addOperands(operandA); odsState.addOperands(operandB); odsState.addOperands(operandC); ::llvm::copy(::llvm::ArrayRef({static_cast(operandA.size()), static_cast(operandB.size()), static_cast(operandC.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().shape = shape; if (b1Op) { odsState.getOrAddProperties().b1Op = b1Op; } if (intOverflowBehavior) { odsState.getOrAddProperties().intOverflowBehavior = intOverflowBehavior; } odsState.getOrAddProperties().layoutA = layoutA; odsState.getOrAddProperties().layoutB = layoutB; if (multiplicandAPtxType) { odsState.getOrAddProperties().multiplicandAPtxType = multiplicandAPtxType; } if (multiplicandBPtxType) { odsState.getOrAddProperties().multiplicandBPtxType = multiplicandBPtxType; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MmaOp MmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAB1OpAttr b1Op, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(shape), std::forward(b1Op), std::forward(intOverflowBehavior), std::forward(layoutA), std::forward(layoutB), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(operandA), std::forward(operandB), std::forward(operandC)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaOp MmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAB1OpAttr b1Op, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(shape), std::forward(b1Op), std::forward(intOverflowBehavior), std::forward(layoutA), std::forward(layoutB), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(operandA), std::forward(operandB), std::forward(operandC)); } void MmaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAB1OpAttr b1Op, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC) { odsState.addOperands(operandA); odsState.addOperands(operandB); odsState.addOperands(operandC); ::llvm::copy(::llvm::ArrayRef({static_cast(operandA.size()), static_cast(operandB.size()), static_cast(operandC.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().shape = shape; if (b1Op) { odsState.getOrAddProperties().b1Op = b1Op; } if (intOverflowBehavior) { odsState.getOrAddProperties().intOverflowBehavior = intOverflowBehavior; } odsState.getOrAddProperties().layoutA = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layoutA); odsState.getOrAddProperties().layoutB = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layoutB); if (multiplicandAPtxType) { odsState.getOrAddProperties().multiplicandAPtxType = multiplicandAPtxType; } if (multiplicandBPtxType) { odsState.getOrAddProperties().multiplicandBPtxType = multiplicandBPtxType; } odsState.addTypes(res); } MmaOp MmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAB1OpAttr b1Op, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(shape), std::forward(b1Op), std::forward(intOverflowBehavior), std::forward(layoutA), std::forward(layoutB), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(operandA), std::forward(operandB), std::forward(operandC)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaOp MmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAB1OpAttr b1Op, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC) { return create(builder, builder.getLoc(), std::forward(res), std::forward(shape), std::forward(b1Op), std::forward(intOverflowBehavior), std::forward(layoutA), std::forward(layoutB), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(operandA), std::forward(operandB), std::forward(operandC)); } void MmaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAB1OpAttr b1Op, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC) { odsState.addOperands(operandA); odsState.addOperands(operandB); odsState.addOperands(operandC); ::llvm::copy(::llvm::ArrayRef({static_cast(operandA.size()), static_cast(operandB.size()), static_cast(operandC.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().shape = shape; if (b1Op) { odsState.getOrAddProperties().b1Op = b1Op; } if (intOverflowBehavior) { odsState.getOrAddProperties().intOverflowBehavior = intOverflowBehavior; } odsState.getOrAddProperties().layoutA = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layoutA); odsState.getOrAddProperties().layoutB = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layoutB); if (multiplicandAPtxType) { odsState.getOrAddProperties().multiplicandAPtxType = multiplicandAPtxType; } if (multiplicandBPtxType) { odsState.getOrAddProperties().multiplicandBPtxType = multiplicandBPtxType; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MmaOp MmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAB1OpAttr b1Op, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(shape), std::forward(b1Op), std::forward(intOverflowBehavior), std::forward(layoutA), std::forward(layoutB), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(operandA), std::forward(operandB), std::forward(operandC)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaOp MmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAB1OpAttr b1Op, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(shape), std::forward(b1Op), std::forward(intOverflowBehavior), std::forward(layoutA), std::forward(layoutB), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(operandA), std::forward(operandB), std::forward(operandC)); } void MmaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } MmaOp MmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaOp MmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MmaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MmaOp MmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaOp MmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult MmaOp::verifyInvariantsImpl() { auto tblgen_b1Op = getProperties().b1Op; (void)tblgen_b1Op; auto tblgen_intOverflowBehavior = getProperties().intOverflowBehavior; (void)tblgen_intOverflowBehavior; auto tblgen_layoutA = getProperties().layoutA; (void)tblgen_layoutA; if (!tblgen_layoutA) return emitOpError("requires attribute 'layoutA'"); auto tblgen_layoutB = getProperties().layoutB; (void)tblgen_layoutB; if (!tblgen_layoutB) return emitOpError("requires attribute 'layoutB'"); auto tblgen_multiplicandAPtxType = getProperties().multiplicandAPtxType; (void)tblgen_multiplicandAPtxType; auto tblgen_multiplicandBPtxType = getProperties().multiplicandBPtxType; (void)tblgen_multiplicandBPtxType; auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitOpError("requires attribute 'shape'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps38(*this, tblgen_shape, "shape"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps43(*this, tblgen_b1Op, "b1Op"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps44(*this, tblgen_intOverflowBehavior, "intOverflowBehavior"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(*this, tblgen_layoutA, "layoutA"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(*this, tblgen_layoutB, "layoutB"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(*this, tblgen_multiplicandAPtxType, "multiplicandAPtxType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(*this, tblgen_multiplicandBPtxType, "multiplicandBPtxType"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps34(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps34(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps34(*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_NVVMOps35(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MmaOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult MmaOp::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.shape; auto shapeAttrName = ::mlir::StringAttr::get(ctx, "shape"); auto attr = dict.get(shapeAttrName); usedKeys.insert(shapeAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for shape in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `shape` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.b1Op; auto b1OpAttrName = ::mlir::StringAttr::get(ctx, "b1Op"); auto attr = dict.get(b1OpAttrName); usedKeys.insert(b1OpAttrName); if (attr || /*isRequired=*/false) { if (!attr) { emitError() << "expected key entry for b1Op in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `b1Op` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.intOverflowBehavior; auto intOverflowBehaviorAttrName = ::mlir::StringAttr::get(ctx, "intOverflowBehavior"); auto attr = dict.get(intOverflowBehaviorAttrName); usedKeys.insert(intOverflowBehaviorAttrName); if (attr || /*isRequired=*/false) { if (!attr) { emitError() << "expected key entry for intOverflowBehavior in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `intOverflowBehavior` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.layoutA; auto layoutAAttrName = ::mlir::StringAttr::get(ctx, "layoutA"); auto attr = dict.get(layoutAAttrName); usedKeys.insert(layoutAAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for layoutA in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `layoutA` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.layoutB; auto layoutBAttrName = ::mlir::StringAttr::get(ctx, "layoutB"); auto attr = dict.get(layoutBAttrName); usedKeys.insert(layoutBAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for layoutB in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `layoutB` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multiplicandAPtxType; auto multiplicandAPtxTypeAttrName = ::mlir::StringAttr::get(ctx, "multiplicandAPtxType"); auto attr = dict.get(multiplicandAPtxTypeAttrName); usedKeys.insert(multiplicandAPtxTypeAttrName); if (attr || /*isRequired=*/false) { if (!attr) { emitError() << "expected key entry for multiplicandAPtxType in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multiplicandAPtxType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multiplicandBPtxType; auto multiplicandBPtxTypeAttrName = ::mlir::StringAttr::get(ctx, "multiplicandBPtxType"); auto attr = dict.get(multiplicandBPtxTypeAttrName); usedKeys.insert(multiplicandBPtxTypeAttrName); if (attr || /*isRequired=*/false) { if (!attr) { emitError() << "expected key entry for multiplicandBPtxType in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multiplicandBPtxType` 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::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MmaOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::MmaOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MmaSpBlockScaleOp definitions //===----------------------------------------------------------------------===// namespace detail { MmaSpBlockScaleOpGenericAdaptorBase::MmaSpBlockScaleOpGenericAdaptorBase(MmaSpBlockScaleOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair MmaSpBlockScaleOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::NVVM::MMAShapeAttr MmaSpBlockScaleOpGenericAdaptorBase::getShape() { auto attr = getShapeAttr(); return ::llvm::cast<::mlir::NVVM::MMAShapeAttr>(attr); } ::std::optional<::mlir::NVVM::MMATypes> MmaSpBlockScaleOpGenericAdaptorBase::getMultiplicandAPtxType() { auto attr = getMultiplicandAPtxTypeAttr(); return attr ? ::std::optional<::mlir::NVVM::MMATypes>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::NVVM::MMATypes> MmaSpBlockScaleOpGenericAdaptorBase::getMultiplicandBPtxType() { auto attr = getMultiplicandBPtxTypeAttr(); return attr ? ::std::optional<::mlir::NVVM::MMATypes>(attr.getValue()) : (::std::nullopt); } ::mlir::NVVM::ScaleVecSize MmaSpBlockScaleOpGenericAdaptorBase::getScaleVecSize() { auto attr = getScaleVecSizeAttr(); return attr.getValue(); } ::mlir::NVVM::BlockScaleFormat MmaSpBlockScaleOpGenericAdaptorBase::getBlockScaleFormat() { auto attr = getBlockScaleFormatAttr(); return attr.getValue(); } ::mlir::NVVM::MMABlockScaleKind MmaSpBlockScaleOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::mlir::UnitAttr MmaSpBlockScaleOpGenericAdaptorBase::getOrderedMetadataAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().orderedMetadata); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool MmaSpBlockScaleOpGenericAdaptorBase::getOrderedMetadata() { auto attr = getOrderedMetadataAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail MmaSpBlockScaleOpAdaptor::MmaSpBlockScaleOpAdaptor(MmaSpBlockScaleOp op) : MmaSpBlockScaleOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MmaSpBlockScaleOpAdaptor::verify(::mlir::Location loc) { auto tblgen_blockScaleFormat = getProperties().blockScaleFormat; (void)tblgen_blockScaleFormat; if (!tblgen_blockScaleFormat) return emitError(loc, "'nvvm.mma.sp.block_scale' op requires attribute 'blockScaleFormat'"); auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'nvvm.mma.sp.block_scale' op requires attribute 'kind'"); auto tblgen_multiplicandAPtxType = getProperties().multiplicandAPtxType; (void)tblgen_multiplicandAPtxType; auto tblgen_multiplicandBPtxType = getProperties().multiplicandBPtxType; (void)tblgen_multiplicandBPtxType; auto tblgen_orderedMetadata = getProperties().orderedMetadata; (void)tblgen_orderedMetadata; auto tblgen_scaleVecSize = getProperties().scaleVecSize; (void)tblgen_scaleVecSize; if (!tblgen_scaleVecSize) return emitError(loc, "'nvvm.mma.sp.block_scale' op requires attribute 'scaleVecSize'"); auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitError(loc, "'nvvm.mma.sp.block_scale' op requires attribute 'shape'"); if (tblgen_shape && !((::llvm::isa<::mlir::NVVM::MMAShapeAttr>(tblgen_shape)))) return emitError(loc, "'nvvm.mma.sp.block_scale' op attribute 'shape' failed to satisfy constraint: Attribute for MMA operation shape."); if (tblgen_multiplicandAPtxType && !((::llvm::isa<::mlir::NVVM::MMATypesAttr>(tblgen_multiplicandAPtxType)))) return emitError(loc, "'nvvm.mma.sp.block_scale' op attribute 'multiplicandAPtxType' failed to satisfy constraint: NVVM MMA types"); if (tblgen_multiplicandBPtxType && !((::llvm::isa<::mlir::NVVM::MMATypesAttr>(tblgen_multiplicandBPtxType)))) return emitError(loc, "'nvvm.mma.sp.block_scale' op attribute 'multiplicandBPtxType' failed to satisfy constraint: NVVM MMA types"); if (tblgen_scaleVecSize && !((::llvm::isa<::mlir::NVVM::ScaleVecSizeAttr>(tblgen_scaleVecSize)))) return emitError(loc, "'nvvm.mma.sp.block_scale' op attribute 'scaleVecSize' failed to satisfy constraint: MMA Scale Vector Sizes"); if (tblgen_blockScaleFormat && !((::llvm::isa<::mlir::NVVM::BlockScaleFormatAttr>(tblgen_blockScaleFormat)))) return emitError(loc, "'nvvm.mma.sp.block_scale' op attribute 'blockScaleFormat' failed to satisfy constraint: MMA Block Scale Format"); if (tblgen_kind && !((::llvm::isa<::mlir::NVVM::MMABlockScaleKindAttr>(tblgen_kind)))) return emitError(loc, "'nvvm.mma.sp.block_scale' op attribute 'kind' failed to satisfy constraint: Block Scale Kind"); if (tblgen_orderedMetadata && !((::llvm::isa<::mlir::UnitAttr>(tblgen_orderedMetadata)))) return emitError(loc, "'nvvm.mma.sp.block_scale' op attribute 'orderedMetadata' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } std::pair MmaSpBlockScaleOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange MmaSpBlockScaleOp::getOperandAMutable() { 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 MmaSpBlockScaleOp::getOperandBMutable() { 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 MmaSpBlockScaleOp::getOperandCMutable() { 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 MmaSpBlockScaleOp::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.blockScaleFormat; auto attr = dict.get("blockScaleFormat"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `blockScaleFormat` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multiplicandAPtxType; auto attr = dict.get("multiplicandAPtxType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multiplicandAPtxType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multiplicandBPtxType; auto attr = dict.get("multiplicandBPtxType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multiplicandBPtxType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.orderedMetadata; auto attr = dict.get("orderedMetadata"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `orderedMetadata` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.scaleVecSize; auto attr = dict.get("scaleVecSize"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scaleVecSize` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.shape; auto attr = dict.get("shape"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `shape` 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 MmaSpBlockScaleOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.blockScaleFormat; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("blockScaleFormat", propStorage)); } { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", propStorage)); } { const auto &propStorage = prop.multiplicandAPtxType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("multiplicandAPtxType", propStorage)); } { const auto &propStorage = prop.multiplicandBPtxType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("multiplicandBPtxType", propStorage)); } { const auto &propStorage = prop.orderedMetadata; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("orderedMetadata", propStorage)); } { const auto &propStorage = prop.scaleVecSize; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("scaleVecSize", propStorage)); } { const auto &propStorage = prop.shape; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("shape", 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 MmaSpBlockScaleOp::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.blockScaleFormat.getAsOpaquePointer()), llvm::hash_value(prop.kind.getAsOpaquePointer()), llvm::hash_value(prop.multiplicandAPtxType.getAsOpaquePointer()), llvm::hash_value(prop.multiplicandBPtxType.getAsOpaquePointer()), llvm::hash_value(prop.orderedMetadata.getAsOpaquePointer()), llvm::hash_value(prop.scaleVecSize.getAsOpaquePointer()), llvm::hash_value(prop.shape.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional MmaSpBlockScaleOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "blockScaleFormat") return prop.blockScaleFormat; if (name == "kind") return prop.kind; if (name == "multiplicandAPtxType") return prop.multiplicandAPtxType; if (name == "multiplicandBPtxType") return prop.multiplicandBPtxType; if (name == "orderedMetadata") return prop.orderedMetadata; if (name == "scaleVecSize") return prop.scaleVecSize; if (name == "shape") return prop.shape; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void MmaSpBlockScaleOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "blockScaleFormat") { prop.blockScaleFormat = ::llvm::dyn_cast_or_null>(value); return; } if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } if (name == "multiplicandAPtxType") { prop.multiplicandAPtxType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "multiplicandBPtxType") { prop.multiplicandBPtxType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "orderedMetadata") { prop.orderedMetadata = ::llvm::dyn_cast_or_null>(value); return; } if (name == "scaleVecSize") { prop.scaleVecSize = ::llvm::dyn_cast_or_null>(value); return; } if (name == "shape") { prop.shape = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void MmaSpBlockScaleOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.blockScaleFormat) attrs.append("blockScaleFormat", prop.blockScaleFormat); if (prop.kind) attrs.append("kind", prop.kind); if (prop.multiplicandAPtxType) attrs.append("multiplicandAPtxType", prop.multiplicandAPtxType); if (prop.multiplicandBPtxType) attrs.append("multiplicandBPtxType", prop.multiplicandBPtxType); if (prop.orderedMetadata) attrs.append("orderedMetadata", prop.orderedMetadata); if (prop.scaleVecSize) attrs.append("scaleVecSize", prop.scaleVecSize); if (prop.shape) attrs.append("shape", prop.shape); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult MmaSpBlockScaleOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getBlockScaleFormatAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps41(attr, "blockScaleFormat", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps42(attr, "kind", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getMultiplicandAPtxTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(attr, "multiplicandAPtxType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getMultiplicandBPtxTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(attr, "multiplicandBPtxType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getOrderedMetadataAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "orderedMetadata", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getScaleVecSizeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps40(attr, "scaleVecSize", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getShapeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps38(attr, "shape", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MmaSpBlockScaleOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.blockScaleFormat))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.kind))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.multiplicandAPtxType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.multiplicandBPtxType))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.orderedMetadata))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.scaleVecSize))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.shape))) 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 MmaSpBlockScaleOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.blockScaleFormat); writer.writeAttribute(prop.kind); writer.writeOptionalAttribute(prop.multiplicandAPtxType); writer.writeOptionalAttribute(prop.multiplicandBPtxType); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.orderedMetadata); writer.writeAttribute(prop.scaleVecSize); writer.writeAttribute(prop.shape); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::NVVM::MMAShapeAttr MmaSpBlockScaleOp::getShape() { auto attr = getShapeAttr(); return ::llvm::cast<::mlir::NVVM::MMAShapeAttr>(attr); } ::std::optional<::mlir::NVVM::MMATypes> MmaSpBlockScaleOp::getMultiplicandAPtxType() { auto attr = getMultiplicandAPtxTypeAttr(); return attr ? ::std::optional<::mlir::NVVM::MMATypes>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::NVVM::MMATypes> MmaSpBlockScaleOp::getMultiplicandBPtxType() { auto attr = getMultiplicandBPtxTypeAttr(); return attr ? ::std::optional<::mlir::NVVM::MMATypes>(attr.getValue()) : (::std::nullopt); } ::mlir::NVVM::ScaleVecSize MmaSpBlockScaleOp::getScaleVecSize() { auto attr = getScaleVecSizeAttr(); return attr.getValue(); } ::mlir::NVVM::BlockScaleFormat MmaSpBlockScaleOp::getBlockScaleFormat() { auto attr = getBlockScaleFormatAttr(); return attr.getValue(); } ::mlir::NVVM::MMABlockScaleKind MmaSpBlockScaleOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } bool MmaSpBlockScaleOp::getOrderedMetadata() { auto attr = getOrderedMetadataAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void MmaSpBlockScaleOp::setMultiplicandAPtxType(::std::optional<::mlir::NVVM::MMATypes> attrValue) { auto &odsProp = getProperties().multiplicandAPtxType; if (attrValue) odsProp = ::mlir::NVVM::MMATypesAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void MmaSpBlockScaleOp::setMultiplicandBPtxType(::std::optional<::mlir::NVVM::MMATypes> attrValue) { auto &odsProp = getProperties().multiplicandBPtxType; if (attrValue) odsProp = ::mlir::NVVM::MMATypesAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void MmaSpBlockScaleOp::setScaleVecSize(::mlir::NVVM::ScaleVecSize attrValue) { getProperties().scaleVecSize = ::mlir::NVVM::ScaleVecSizeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MmaSpBlockScaleOp::setBlockScaleFormat(::mlir::NVVM::BlockScaleFormat attrValue) { getProperties().blockScaleFormat = ::mlir::NVVM::BlockScaleFormatAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MmaSpBlockScaleOp::setKind(::mlir::NVVM::MMABlockScaleKind attrValue) { getProperties().kind = ::mlir::NVVM::MMABlockScaleKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MmaSpBlockScaleOp::setOrderedMetadata(bool attrValue) { auto &odsProp = getProperties().orderedMetadata; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } MmaSpBlockScaleOp MmaSpBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType, ValueRange operandA, ValueRange operandB, ValueRange operandC, Value sparseMetadata, Value sparsitySelector, Value scaleAData, Value byteIdA, Value threadIdA, Value scaleBData, Value byteIdB, Value threadIdB, ArrayRef shape, std::optional> multiplicandPtxTypes, ScaleVecSize scaleVecSize, BlockScaleFormat blockScaleFormat, MMABlockScaleKind kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB), std::forward(shape), std::forward(multiplicandPtxTypes), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaSpBlockScaleOp MmaSpBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType, ValueRange operandA, ValueRange operandB, ValueRange operandC, Value sparseMetadata, Value sparsitySelector, Value scaleAData, Value byteIdA, Value threadIdA, Value scaleBData, Value byteIdB, Value threadIdB, ArrayRef shape, std::optional> multiplicandPtxTypes, ScaleVecSize scaleVecSize, BlockScaleFormat blockScaleFormat, MMABlockScaleKind kind) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB), std::forward(shape), std::forward(multiplicandPtxTypes), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind)); } void MmaSpBlockScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSizeAttr scaleVecSize, ::mlir::NVVM::BlockScaleFormatAttr blockScaleFormat, ::mlir::NVVM::MMABlockScaleKindAttr kind, /*optional*/::mlir::UnitAttr orderedMetadata, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { odsState.addOperands(operandA); odsState.addOperands(operandB); odsState.addOperands(operandC); odsState.addOperands(sparseMetadata); odsState.addOperands(sparsitySelector); odsState.addOperands(scaleAData); odsState.addOperands(byteIdA); odsState.addOperands(threadIdA); odsState.addOperands(scaleBData); odsState.addOperands(byteIdB); odsState.addOperands(threadIdB); ::llvm::copy(::llvm::ArrayRef({static_cast(operandA.size()), static_cast(operandB.size()), static_cast(operandC.size()), 1, 1, 1, 1, 1, 1, 1, 1}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().shape = shape; if (multiplicandAPtxType) { odsState.getOrAddProperties().multiplicandAPtxType = multiplicandAPtxType; } if (multiplicandBPtxType) { odsState.getOrAddProperties().multiplicandBPtxType = multiplicandBPtxType; } odsState.getOrAddProperties().scaleVecSize = scaleVecSize; odsState.getOrAddProperties().blockScaleFormat = blockScaleFormat; odsState.getOrAddProperties().kind = kind; if (orderedMetadata) { odsState.getOrAddProperties().orderedMetadata = orderedMetadata; } odsState.addTypes(res); } MmaSpBlockScaleOp MmaSpBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSizeAttr scaleVecSize, ::mlir::NVVM::BlockScaleFormatAttr blockScaleFormat, ::mlir::NVVM::MMABlockScaleKindAttr kind, /*optional*/::mlir::UnitAttr orderedMetadata, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(shape), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind), std::forward(orderedMetadata), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaSpBlockScaleOp MmaSpBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSizeAttr scaleVecSize, ::mlir::NVVM::BlockScaleFormatAttr blockScaleFormat, ::mlir::NVVM::MMABlockScaleKindAttr kind, /*optional*/::mlir::UnitAttr orderedMetadata, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { return create(builder, builder.getLoc(), std::forward(res), std::forward(shape), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind), std::forward(orderedMetadata), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB)); } void MmaSpBlockScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSizeAttr scaleVecSize, ::mlir::NVVM::BlockScaleFormatAttr blockScaleFormat, ::mlir::NVVM::MMABlockScaleKindAttr kind, /*optional*/::mlir::UnitAttr orderedMetadata, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { odsState.addOperands(operandA); odsState.addOperands(operandB); odsState.addOperands(operandC); odsState.addOperands(sparseMetadata); odsState.addOperands(sparsitySelector); odsState.addOperands(scaleAData); odsState.addOperands(byteIdA); odsState.addOperands(threadIdA); odsState.addOperands(scaleBData); odsState.addOperands(byteIdB); odsState.addOperands(threadIdB); ::llvm::copy(::llvm::ArrayRef({static_cast(operandA.size()), static_cast(operandB.size()), static_cast(operandC.size()), 1, 1, 1, 1, 1, 1, 1, 1}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().shape = shape; if (multiplicandAPtxType) { odsState.getOrAddProperties().multiplicandAPtxType = multiplicandAPtxType; } if (multiplicandBPtxType) { odsState.getOrAddProperties().multiplicandBPtxType = multiplicandBPtxType; } odsState.getOrAddProperties().scaleVecSize = scaleVecSize; odsState.getOrAddProperties().blockScaleFormat = blockScaleFormat; odsState.getOrAddProperties().kind = kind; if (orderedMetadata) { odsState.getOrAddProperties().orderedMetadata = orderedMetadata; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MmaSpBlockScaleOp MmaSpBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSizeAttr scaleVecSize, ::mlir::NVVM::BlockScaleFormatAttr blockScaleFormat, ::mlir::NVVM::MMABlockScaleKindAttr kind, /*optional*/::mlir::UnitAttr orderedMetadata, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(shape), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind), std::forward(orderedMetadata), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaSpBlockScaleOp MmaSpBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSizeAttr scaleVecSize, ::mlir::NVVM::BlockScaleFormatAttr blockScaleFormat, ::mlir::NVVM::MMABlockScaleKindAttr kind, /*optional*/::mlir::UnitAttr orderedMetadata, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(shape), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind), std::forward(orderedMetadata), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB)); } void MmaSpBlockScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSize scaleVecSize, ::mlir::NVVM::BlockScaleFormat blockScaleFormat, ::mlir::NVVM::MMABlockScaleKind kind, /*optional*/bool orderedMetadata, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { odsState.addOperands(operandA); odsState.addOperands(operandB); odsState.addOperands(operandC); odsState.addOperands(sparseMetadata); odsState.addOperands(sparsitySelector); odsState.addOperands(scaleAData); odsState.addOperands(byteIdA); odsState.addOperands(threadIdA); odsState.addOperands(scaleBData); odsState.addOperands(byteIdB); odsState.addOperands(threadIdB); ::llvm::copy(::llvm::ArrayRef({static_cast(operandA.size()), static_cast(operandB.size()), static_cast(operandC.size()), 1, 1, 1, 1, 1, 1, 1, 1}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().shape = shape; if (multiplicandAPtxType) { odsState.getOrAddProperties().multiplicandAPtxType = multiplicandAPtxType; } if (multiplicandBPtxType) { odsState.getOrAddProperties().multiplicandBPtxType = multiplicandBPtxType; } odsState.getOrAddProperties().scaleVecSize = ::mlir::NVVM::ScaleVecSizeAttr::get(odsBuilder.getContext(), scaleVecSize); odsState.getOrAddProperties().blockScaleFormat = ::mlir::NVVM::BlockScaleFormatAttr::get(odsBuilder.getContext(), blockScaleFormat); odsState.getOrAddProperties().kind = ::mlir::NVVM::MMABlockScaleKindAttr::get(odsBuilder.getContext(), kind); if (orderedMetadata) { odsState.getOrAddProperties().orderedMetadata = ((orderedMetadata) ? odsBuilder.getUnitAttr() : nullptr); } odsState.addTypes(res); } MmaSpBlockScaleOp MmaSpBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSize scaleVecSize, ::mlir::NVVM::BlockScaleFormat blockScaleFormat, ::mlir::NVVM::MMABlockScaleKind kind, /*optional*/bool orderedMetadata, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(shape), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind), std::forward(orderedMetadata), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaSpBlockScaleOp MmaSpBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSize scaleVecSize, ::mlir::NVVM::BlockScaleFormat blockScaleFormat, ::mlir::NVVM::MMABlockScaleKind kind, /*optional*/bool orderedMetadata, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { return create(builder, builder.getLoc(), std::forward(res), std::forward(shape), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind), std::forward(orderedMetadata), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB)); } void MmaSpBlockScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSize scaleVecSize, ::mlir::NVVM::BlockScaleFormat blockScaleFormat, ::mlir::NVVM::MMABlockScaleKind kind, /*optional*/bool orderedMetadata, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { odsState.addOperands(operandA); odsState.addOperands(operandB); odsState.addOperands(operandC); odsState.addOperands(sparseMetadata); odsState.addOperands(sparsitySelector); odsState.addOperands(scaleAData); odsState.addOperands(byteIdA); odsState.addOperands(threadIdA); odsState.addOperands(scaleBData); odsState.addOperands(byteIdB); odsState.addOperands(threadIdB); ::llvm::copy(::llvm::ArrayRef({static_cast(operandA.size()), static_cast(operandB.size()), static_cast(operandC.size()), 1, 1, 1, 1, 1, 1, 1, 1}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().shape = shape; if (multiplicandAPtxType) { odsState.getOrAddProperties().multiplicandAPtxType = multiplicandAPtxType; } if (multiplicandBPtxType) { odsState.getOrAddProperties().multiplicandBPtxType = multiplicandBPtxType; } odsState.getOrAddProperties().scaleVecSize = ::mlir::NVVM::ScaleVecSizeAttr::get(odsBuilder.getContext(), scaleVecSize); odsState.getOrAddProperties().blockScaleFormat = ::mlir::NVVM::BlockScaleFormatAttr::get(odsBuilder.getContext(), blockScaleFormat); odsState.getOrAddProperties().kind = ::mlir::NVVM::MMABlockScaleKindAttr::get(odsBuilder.getContext(), kind); if (orderedMetadata) { odsState.getOrAddProperties().orderedMetadata = ((orderedMetadata) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MmaSpBlockScaleOp MmaSpBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSize scaleVecSize, ::mlir::NVVM::BlockScaleFormat blockScaleFormat, ::mlir::NVVM::MMABlockScaleKind kind, /*optional*/bool orderedMetadata, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(shape), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind), std::forward(orderedMetadata), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaSpBlockScaleOp MmaSpBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, ::mlir::NVVM::ScaleVecSize scaleVecSize, ::mlir::NVVM::BlockScaleFormat blockScaleFormat, ::mlir::NVVM::MMABlockScaleKind kind, /*optional*/bool orderedMetadata, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector, ::mlir::Value scaleAData, ::mlir::Value byteIdA, ::mlir::Value threadIdA, ::mlir::Value scaleBData, ::mlir::Value byteIdB, ::mlir::Value threadIdB) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(shape), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(scaleVecSize), std::forward(blockScaleFormat), std::forward(kind), std::forward(orderedMetadata), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector), std::forward(scaleAData), std::forward(byteIdA), std::forward(threadIdA), std::forward(scaleBData), std::forward(byteIdB), std::forward(threadIdB)); } void MmaSpBlockScaleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 8u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } MmaSpBlockScaleOp MmaSpBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaSpBlockScaleOp MmaSpBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MmaSpBlockScaleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 8u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MmaSpBlockScaleOp MmaSpBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaSpBlockScaleOp MmaSpBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult MmaSpBlockScaleOp::verifyInvariantsImpl() { auto tblgen_blockScaleFormat = getProperties().blockScaleFormat; (void)tblgen_blockScaleFormat; if (!tblgen_blockScaleFormat) return emitOpError("requires attribute 'blockScaleFormat'"); auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); auto tblgen_multiplicandAPtxType = getProperties().multiplicandAPtxType; (void)tblgen_multiplicandAPtxType; auto tblgen_multiplicandBPtxType = getProperties().multiplicandBPtxType; (void)tblgen_multiplicandBPtxType; auto tblgen_orderedMetadata = getProperties().orderedMetadata; (void)tblgen_orderedMetadata; auto tblgen_scaleVecSize = getProperties().scaleVecSize; (void)tblgen_scaleVecSize; if (!tblgen_scaleVecSize) return emitOpError("requires attribute 'scaleVecSize'"); auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitOpError("requires attribute 'shape'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps38(*this, tblgen_shape, "shape"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(*this, tblgen_multiplicandAPtxType, "multiplicandAPtxType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(*this, tblgen_multiplicandBPtxType, "multiplicandBPtxType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps40(*this, tblgen_scaleVecSize, "scaleVecSize"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps41(*this, tblgen_blockScaleFormat, "blockScaleFormat"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps42(*this, tblgen_kind, "kind"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_orderedMetadata, "orderedMetadata"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps34(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps34(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps34(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup5 = getODSOperands(5); for (auto v : valueGroup5) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup6 = getODSOperands(6); for (auto v : valueGroup6) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup7 = getODSOperands(7); for (auto v : valueGroup7) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup8 = getODSOperands(8); for (auto v : valueGroup8) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup9 = getODSOperands(9); for (auto v : valueGroup9) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup10 = getODSOperands(10); for (auto v : valueGroup10) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps11(*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_NVVMOps35(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MmaSpBlockScaleOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult MmaSpBlockScaleOp::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.shape; auto shapeAttrName = ::mlir::StringAttr::get(ctx, "shape"); auto attr = dict.get(shapeAttrName); usedKeys.insert(shapeAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for shape in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `shape` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multiplicandAPtxType; auto multiplicandAPtxTypeAttrName = ::mlir::StringAttr::get(ctx, "multiplicandAPtxType"); auto attr = dict.get(multiplicandAPtxTypeAttrName); usedKeys.insert(multiplicandAPtxTypeAttrName); if (attr || /*isRequired=*/false) { if (!attr) { emitError() << "expected key entry for multiplicandAPtxType in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multiplicandAPtxType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multiplicandBPtxType; auto multiplicandBPtxTypeAttrName = ::mlir::StringAttr::get(ctx, "multiplicandBPtxType"); auto attr = dict.get(multiplicandBPtxTypeAttrName); usedKeys.insert(multiplicandBPtxTypeAttrName); if (attr || /*isRequired=*/false) { if (!attr) { emitError() << "expected key entry for multiplicandBPtxType in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multiplicandBPtxType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.scaleVecSize; auto scaleVecSizeAttrName = ::mlir::StringAttr::get(ctx, "scaleVecSize"); auto attr = dict.get(scaleVecSizeAttrName); usedKeys.insert(scaleVecSizeAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for scaleVecSize in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scaleVecSize` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.blockScaleFormat; auto blockScaleFormatAttrName = ::mlir::StringAttr::get(ctx, "blockScaleFormat"); auto attr = dict.get(blockScaleFormatAttrName); usedKeys.insert(blockScaleFormatAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for blockScaleFormat in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `blockScaleFormat` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.kind; auto kindAttrName = ::mlir::StringAttr::get(ctx, "kind"); auto attr = dict.get(kindAttrName); usedKeys.insert(kindAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for kind in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.orderedMetadata; auto orderedMetadataAttrName = ::mlir::StringAttr::get(ctx, "orderedMetadata"); auto attr = dict.get(orderedMetadataAttrName); usedKeys.insert(orderedMetadataAttrName); if (attr || /*isRequired=*/false) { if (!attr) { emitError() << "expected key entry for orderedMetadata in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `orderedMetadata` 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::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MmaSpBlockScaleOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::MmaSpBlockScaleOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MmaSpOp definitions //===----------------------------------------------------------------------===// namespace detail { MmaSpOpGenericAdaptorBase::MmaSpOpGenericAdaptorBase(MmaSpOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair MmaSpOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::NVVM::MMAShapeAttr MmaSpOpGenericAdaptorBase::getShape() { auto attr = getShapeAttr(); return ::llvm::cast<::mlir::NVVM::MMAShapeAttr>(attr); } ::std::optional<::mlir::NVVM::MMAIntOverflow> MmaSpOpGenericAdaptorBase::getIntOverflowBehavior() { auto attr = getIntOverflowBehaviorAttr(); return attr ? ::std::optional<::mlir::NVVM::MMAIntOverflow>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::NVVM::MMATypes> MmaSpOpGenericAdaptorBase::getMultiplicandAPtxType() { auto attr = getMultiplicandAPtxTypeAttr(); return attr ? ::std::optional<::mlir::NVVM::MMATypes>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::NVVM::MMATypes> MmaSpOpGenericAdaptorBase::getMultiplicandBPtxType() { auto attr = getMultiplicandBPtxTypeAttr(); return attr ? ::std::optional<::mlir::NVVM::MMATypes>(attr.getValue()) : (::std::nullopt); } ::mlir::UnitAttr MmaSpOpGenericAdaptorBase::getOrderedMetadataAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().orderedMetadata); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool MmaSpOpGenericAdaptorBase::getOrderedMetadata() { auto attr = getOrderedMetadataAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::std::optional<::mlir::NVVM::MMAKind> MmaSpOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr ? ::std::optional<::mlir::NVVM::MMAKind>(attr.getValue()) : (::std::nullopt); } } // namespace detail MmaSpOpAdaptor::MmaSpOpAdaptor(MmaSpOp op) : MmaSpOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MmaSpOpAdaptor::verify(::mlir::Location loc) { auto tblgen_intOverflowBehavior = getProperties().intOverflowBehavior; (void)tblgen_intOverflowBehavior; auto tblgen_kind = getProperties().kind; (void)tblgen_kind; auto tblgen_multiplicandAPtxType = getProperties().multiplicandAPtxType; (void)tblgen_multiplicandAPtxType; auto tblgen_multiplicandBPtxType = getProperties().multiplicandBPtxType; (void)tblgen_multiplicandBPtxType; auto tblgen_orderedMetadata = getProperties().orderedMetadata; (void)tblgen_orderedMetadata; auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitError(loc, "'nvvm.mma.sp.sync' op requires attribute 'shape'"); if (tblgen_shape && !((::llvm::isa<::mlir::NVVM::MMAShapeAttr>(tblgen_shape)))) return emitError(loc, "'nvvm.mma.sp.sync' op attribute 'shape' failed to satisfy constraint: Attribute for MMA operation shape."); if (tblgen_intOverflowBehavior && !((::llvm::isa<::mlir::NVVM::MMAIntOverflowAttr>(tblgen_intOverflowBehavior)))) return emitError(loc, "'nvvm.mma.sp.sync' op attribute 'intOverflowBehavior' failed to satisfy constraint: MMA overflow options"); if (tblgen_multiplicandAPtxType && !((::llvm::isa<::mlir::NVVM::MMATypesAttr>(tblgen_multiplicandAPtxType)))) return emitError(loc, "'nvvm.mma.sp.sync' op attribute 'multiplicandAPtxType' failed to satisfy constraint: NVVM MMA types"); if (tblgen_multiplicandBPtxType && !((::llvm::isa<::mlir::NVVM::MMATypesAttr>(tblgen_multiplicandBPtxType)))) return emitError(loc, "'nvvm.mma.sp.sync' op attribute 'multiplicandBPtxType' failed to satisfy constraint: NVVM MMA types"); if (tblgen_orderedMetadata && !((::llvm::isa<::mlir::UnitAttr>(tblgen_orderedMetadata)))) return emitError(loc, "'nvvm.mma.sp.sync' op attribute 'orderedMetadata' failed to satisfy constraint: unit attribute"); if (tblgen_kind && !((::llvm::isa<::mlir::NVVM::MMAKindAttr>(tblgen_kind)))) return emitError(loc, "'nvvm.mma.sp.sync' op attribute 'kind' failed to satisfy constraint: MMA operation kind"); return ::mlir::success(); } std::pair MmaSpOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange MmaSpOp::getOperandAMutable() { 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 MmaSpOp::getOperandBMutable() { 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 MmaSpOp::getOperandCMutable() { 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 MmaSpOp::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.intOverflowBehavior; auto attr = dict.get("intOverflowBehavior"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `intOverflowBehavior` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multiplicandAPtxType; auto attr = dict.get("multiplicandAPtxType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multiplicandAPtxType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multiplicandBPtxType; auto attr = dict.get("multiplicandBPtxType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multiplicandBPtxType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.orderedMetadata; auto attr = dict.get("orderedMetadata"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `orderedMetadata` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.shape; auto attr = dict.get("shape"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `shape` 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 MmaSpOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.intOverflowBehavior; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("intOverflowBehavior", propStorage)); } { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", propStorage)); } { const auto &propStorage = prop.multiplicandAPtxType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("multiplicandAPtxType", propStorage)); } { const auto &propStorage = prop.multiplicandBPtxType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("multiplicandBPtxType", propStorage)); } { const auto &propStorage = prop.orderedMetadata; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("orderedMetadata", propStorage)); } { const auto &propStorage = prop.shape; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("shape", 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 MmaSpOp::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.intOverflowBehavior.getAsOpaquePointer()), llvm::hash_value(prop.kind.getAsOpaquePointer()), llvm::hash_value(prop.multiplicandAPtxType.getAsOpaquePointer()), llvm::hash_value(prop.multiplicandBPtxType.getAsOpaquePointer()), llvm::hash_value(prop.orderedMetadata.getAsOpaquePointer()), llvm::hash_value(prop.shape.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional MmaSpOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "intOverflowBehavior") return prop.intOverflowBehavior; if (name == "kind") return prop.kind; if (name == "multiplicandAPtxType") return prop.multiplicandAPtxType; if (name == "multiplicandBPtxType") return prop.multiplicandBPtxType; if (name == "orderedMetadata") return prop.orderedMetadata; if (name == "shape") return prop.shape; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void MmaSpOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "intOverflowBehavior") { prop.intOverflowBehavior = ::llvm::dyn_cast_or_null>(value); return; } if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } if (name == "multiplicandAPtxType") { prop.multiplicandAPtxType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "multiplicandBPtxType") { prop.multiplicandBPtxType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "orderedMetadata") { prop.orderedMetadata = ::llvm::dyn_cast_or_null>(value); return; } if (name == "shape") { prop.shape = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void MmaSpOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.intOverflowBehavior) attrs.append("intOverflowBehavior", prop.intOverflowBehavior); if (prop.kind) attrs.append("kind", prop.kind); if (prop.multiplicandAPtxType) attrs.append("multiplicandAPtxType", prop.multiplicandAPtxType); if (prop.multiplicandBPtxType) attrs.append("multiplicandBPtxType", prop.multiplicandBPtxType); if (prop.orderedMetadata) attrs.append("orderedMetadata", prop.orderedMetadata); if (prop.shape) attrs.append("shape", prop.shape); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult MmaSpOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getIntOverflowBehaviorAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps44(attr, "intOverflowBehavior", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps45(attr, "kind", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getMultiplicandAPtxTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(attr, "multiplicandAPtxType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getMultiplicandBPtxTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(attr, "multiplicandBPtxType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getOrderedMetadataAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "orderedMetadata", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getShapeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps38(attr, "shape", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MmaSpOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.intOverflowBehavior))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.kind))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.multiplicandAPtxType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.multiplicandBPtxType))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.orderedMetadata))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.shape))) 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 MmaSpOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.intOverflowBehavior); writer.writeOptionalAttribute(prop.kind); writer.writeOptionalAttribute(prop.multiplicandAPtxType); writer.writeOptionalAttribute(prop.multiplicandBPtxType); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.orderedMetadata); writer.writeAttribute(prop.shape); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::NVVM::MMAShapeAttr MmaSpOp::getShape() { auto attr = getShapeAttr(); return ::llvm::cast<::mlir::NVVM::MMAShapeAttr>(attr); } ::std::optional<::mlir::NVVM::MMAIntOverflow> MmaSpOp::getIntOverflowBehavior() { auto attr = getIntOverflowBehaviorAttr(); return attr ? ::std::optional<::mlir::NVVM::MMAIntOverflow>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::NVVM::MMATypes> MmaSpOp::getMultiplicandAPtxType() { auto attr = getMultiplicandAPtxTypeAttr(); return attr ? ::std::optional<::mlir::NVVM::MMATypes>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::NVVM::MMATypes> MmaSpOp::getMultiplicandBPtxType() { auto attr = getMultiplicandBPtxTypeAttr(); return attr ? ::std::optional<::mlir::NVVM::MMATypes>(attr.getValue()) : (::std::nullopt); } bool MmaSpOp::getOrderedMetadata() { auto attr = getOrderedMetadataAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::std::optional<::mlir::NVVM::MMAKind> MmaSpOp::getKind() { auto attr = getKindAttr(); return attr ? ::std::optional<::mlir::NVVM::MMAKind>(attr.getValue()) : (::std::nullopt); } void MmaSpOp::setIntOverflowBehavior(::std::optional<::mlir::NVVM::MMAIntOverflow> attrValue) { auto &odsProp = getProperties().intOverflowBehavior; if (attrValue) odsProp = ::mlir::NVVM::MMAIntOverflowAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void MmaSpOp::setMultiplicandAPtxType(::std::optional<::mlir::NVVM::MMATypes> attrValue) { auto &odsProp = getProperties().multiplicandAPtxType; if (attrValue) odsProp = ::mlir::NVVM::MMATypesAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void MmaSpOp::setMultiplicandBPtxType(::std::optional<::mlir::NVVM::MMATypes> attrValue) { auto &odsProp = getProperties().multiplicandBPtxType; if (attrValue) odsProp = ::mlir::NVVM::MMATypesAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void MmaSpOp::setOrderedMetadata(bool attrValue) { auto &odsProp = getProperties().orderedMetadata; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void MmaSpOp::setKind(::std::optional<::mlir::NVVM::MMAKind> attrValue) { auto &odsProp = getProperties().kind; if (attrValue) odsProp = ::mlir::NVVM::MMAKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } MmaSpOp MmaSpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType, ValueRange operandA, ValueRange operandB, ValueRange operandC, Value sparseMetadata, Value sparsitySelector, ArrayRef shape, std::optional intOverflow, std::optional> multiplicandPtxTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector), std::forward(shape), std::forward(intOverflow), std::forward(multiplicandPtxTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaSpOp MmaSpOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType, ValueRange operandA, ValueRange operandB, ValueRange operandC, Value sparseMetadata, Value sparsitySelector, ArrayRef shape, std::optional intOverflow, std::optional> multiplicandPtxTypes) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector), std::forward(shape), std::forward(intOverflow), std::forward(multiplicandPtxTypes)); } void MmaSpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, /*optional*/::mlir::UnitAttr orderedMetadata, /*optional*/::mlir::NVVM::MMAKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector) { odsState.addOperands(operandA); odsState.addOperands(operandB); odsState.addOperands(operandC); odsState.addOperands(sparseMetadata); odsState.addOperands(sparsitySelector); ::llvm::copy(::llvm::ArrayRef({static_cast(operandA.size()), static_cast(operandB.size()), static_cast(operandC.size()), 1, 1}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().shape = shape; if (intOverflowBehavior) { odsState.getOrAddProperties().intOverflowBehavior = intOverflowBehavior; } if (multiplicandAPtxType) { odsState.getOrAddProperties().multiplicandAPtxType = multiplicandAPtxType; } if (multiplicandBPtxType) { odsState.getOrAddProperties().multiplicandBPtxType = multiplicandBPtxType; } if (orderedMetadata) { odsState.getOrAddProperties().orderedMetadata = orderedMetadata; } if (kind) { odsState.getOrAddProperties().kind = kind; } odsState.addTypes(res); } MmaSpOp MmaSpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, /*optional*/::mlir::UnitAttr orderedMetadata, /*optional*/::mlir::NVVM::MMAKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(shape), std::forward(intOverflowBehavior), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(orderedMetadata), std::forward(kind), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaSpOp MmaSpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, /*optional*/::mlir::UnitAttr orderedMetadata, /*optional*/::mlir::NVVM::MMAKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector) { return create(builder, builder.getLoc(), std::forward(res), std::forward(shape), std::forward(intOverflowBehavior), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(orderedMetadata), std::forward(kind), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector)); } void MmaSpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, /*optional*/::mlir::UnitAttr orderedMetadata, /*optional*/::mlir::NVVM::MMAKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector) { odsState.addOperands(operandA); odsState.addOperands(operandB); odsState.addOperands(operandC); odsState.addOperands(sparseMetadata); odsState.addOperands(sparsitySelector); ::llvm::copy(::llvm::ArrayRef({static_cast(operandA.size()), static_cast(operandB.size()), static_cast(operandC.size()), 1, 1}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().shape = shape; if (intOverflowBehavior) { odsState.getOrAddProperties().intOverflowBehavior = intOverflowBehavior; } if (multiplicandAPtxType) { odsState.getOrAddProperties().multiplicandAPtxType = multiplicandAPtxType; } if (multiplicandBPtxType) { odsState.getOrAddProperties().multiplicandBPtxType = multiplicandBPtxType; } if (orderedMetadata) { odsState.getOrAddProperties().orderedMetadata = orderedMetadata; } if (kind) { odsState.getOrAddProperties().kind = kind; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MmaSpOp MmaSpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, /*optional*/::mlir::UnitAttr orderedMetadata, /*optional*/::mlir::NVVM::MMAKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(shape), std::forward(intOverflowBehavior), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(orderedMetadata), std::forward(kind), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaSpOp MmaSpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, /*optional*/::mlir::UnitAttr orderedMetadata, /*optional*/::mlir::NVVM::MMAKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(shape), std::forward(intOverflowBehavior), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(orderedMetadata), std::forward(kind), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector)); } void MmaSpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, /*optional*/bool orderedMetadata, /*optional*/::mlir::NVVM::MMAKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector) { odsState.addOperands(operandA); odsState.addOperands(operandB); odsState.addOperands(operandC); odsState.addOperands(sparseMetadata); odsState.addOperands(sparsitySelector); ::llvm::copy(::llvm::ArrayRef({static_cast(operandA.size()), static_cast(operandB.size()), static_cast(operandC.size()), 1, 1}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().shape = shape; if (intOverflowBehavior) { odsState.getOrAddProperties().intOverflowBehavior = intOverflowBehavior; } if (multiplicandAPtxType) { odsState.getOrAddProperties().multiplicandAPtxType = multiplicandAPtxType; } if (multiplicandBPtxType) { odsState.getOrAddProperties().multiplicandBPtxType = multiplicandBPtxType; } if (orderedMetadata) { odsState.getOrAddProperties().orderedMetadata = ((orderedMetadata) ? odsBuilder.getUnitAttr() : nullptr); } if (kind) { odsState.getOrAddProperties().kind = kind; } odsState.addTypes(res); } MmaSpOp MmaSpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, /*optional*/bool orderedMetadata, /*optional*/::mlir::NVVM::MMAKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(shape), std::forward(intOverflowBehavior), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(orderedMetadata), std::forward(kind), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaSpOp MmaSpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, /*optional*/bool orderedMetadata, /*optional*/::mlir::NVVM::MMAKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector) { return create(builder, builder.getLoc(), std::forward(res), std::forward(shape), std::forward(intOverflowBehavior), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(orderedMetadata), std::forward(kind), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector)); } void MmaSpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, /*optional*/bool orderedMetadata, /*optional*/::mlir::NVVM::MMAKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector) { odsState.addOperands(operandA); odsState.addOperands(operandB); odsState.addOperands(operandC); odsState.addOperands(sparseMetadata); odsState.addOperands(sparsitySelector); ::llvm::copy(::llvm::ArrayRef({static_cast(operandA.size()), static_cast(operandB.size()), static_cast(operandC.size()), 1, 1}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().shape = shape; if (intOverflowBehavior) { odsState.getOrAddProperties().intOverflowBehavior = intOverflowBehavior; } if (multiplicandAPtxType) { odsState.getOrAddProperties().multiplicandAPtxType = multiplicandAPtxType; } if (multiplicandBPtxType) { odsState.getOrAddProperties().multiplicandBPtxType = multiplicandBPtxType; } if (orderedMetadata) { odsState.getOrAddProperties().orderedMetadata = ((orderedMetadata) ? odsBuilder.getUnitAttr() : nullptr); } if (kind) { odsState.getOrAddProperties().kind = kind; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MmaSpOp MmaSpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, /*optional*/bool orderedMetadata, /*optional*/::mlir::NVVM::MMAKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(shape), std::forward(intOverflowBehavior), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(orderedMetadata), std::forward(kind), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaSpOp MmaSpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::MMAShapeAttr shape, /*optional*/::mlir::NVVM::MMAIntOverflowAttr intOverflowBehavior, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandAPtxType, /*optional*/::mlir::NVVM::MMATypesAttr multiplicandBPtxType, /*optional*/bool orderedMetadata, /*optional*/::mlir::NVVM::MMAKindAttr kind, ::mlir::ValueRange operandA, ::mlir::ValueRange operandB, ::mlir::ValueRange operandC, ::mlir::Value sparseMetadata, ::mlir::Value sparsitySelector) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(shape), std::forward(intOverflowBehavior), std::forward(multiplicandAPtxType), std::forward(multiplicandBPtxType), std::forward(orderedMetadata), std::forward(kind), std::forward(operandA), std::forward(operandB), std::forward(operandC), std::forward(sparseMetadata), std::forward(sparsitySelector)); } void MmaSpOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } MmaSpOp MmaSpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaSpOp MmaSpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MmaSpOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MmaSpOp MmaSpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MmaSpOp MmaSpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult MmaSpOp::verifyInvariantsImpl() { auto tblgen_intOverflowBehavior = getProperties().intOverflowBehavior; (void)tblgen_intOverflowBehavior; auto tblgen_kind = getProperties().kind; (void)tblgen_kind; auto tblgen_multiplicandAPtxType = getProperties().multiplicandAPtxType; (void)tblgen_multiplicandAPtxType; auto tblgen_multiplicandBPtxType = getProperties().multiplicandBPtxType; (void)tblgen_multiplicandBPtxType; auto tblgen_orderedMetadata = getProperties().orderedMetadata; (void)tblgen_orderedMetadata; auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitOpError("requires attribute 'shape'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps38(*this, tblgen_shape, "shape"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps44(*this, tblgen_intOverflowBehavior, "intOverflowBehavior"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(*this, tblgen_multiplicandAPtxType, "multiplicandAPtxType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(*this, tblgen_multiplicandBPtxType, "multiplicandBPtxType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_orderedMetadata, "orderedMetadata"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps45(*this, tblgen_kind, "kind"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps34(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps34(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps34(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps35(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MmaSpOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult MmaSpOp::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.shape; auto shapeAttrName = ::mlir::StringAttr::get(ctx, "shape"); auto attr = dict.get(shapeAttrName); usedKeys.insert(shapeAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for shape in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `shape` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.intOverflowBehavior; auto intOverflowBehaviorAttrName = ::mlir::StringAttr::get(ctx, "intOverflowBehavior"); auto attr = dict.get(intOverflowBehaviorAttrName); usedKeys.insert(intOverflowBehaviorAttrName); if (attr || /*isRequired=*/false) { if (!attr) { emitError() << "expected key entry for intOverflowBehavior in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `intOverflowBehavior` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multiplicandAPtxType; auto multiplicandAPtxTypeAttrName = ::mlir::StringAttr::get(ctx, "multiplicandAPtxType"); auto attr = dict.get(multiplicandAPtxTypeAttrName); usedKeys.insert(multiplicandAPtxTypeAttrName); if (attr || /*isRequired=*/false) { if (!attr) { emitError() << "expected key entry for multiplicandAPtxType in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multiplicandAPtxType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multiplicandBPtxType; auto multiplicandBPtxTypeAttrName = ::mlir::StringAttr::get(ctx, "multiplicandBPtxType"); auto attr = dict.get(multiplicandBPtxTypeAttrName); usedKeys.insert(multiplicandBPtxTypeAttrName); if (attr || /*isRequired=*/false) { if (!attr) { emitError() << "expected key entry for multiplicandBPtxType in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multiplicandBPtxType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.orderedMetadata; auto orderedMetadataAttrName = ::mlir::StringAttr::get(ctx, "orderedMetadata"); auto attr = dict.get(orderedMetadataAttrName); usedKeys.insert(orderedMetadataAttrName); if (attr || /*isRequired=*/false) { if (!attr) { emitError() << "expected key entry for orderedMetadata in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `orderedMetadata` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.kind; auto kindAttrName = ::mlir::StringAttr::get(ctx, "kind"); auto attr = dict.get(kindAttrName); usedKeys.insert(kindAttrName); if (attr || /*isRequired=*/false) { if (!attr) { emitError() << "expected key entry for kind in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` 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::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MmaSpOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::MmaSpOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::MovMatrixOp definitions //===----------------------------------------------------------------------===// namespace detail { MovMatrixOpGenericAdaptorBase::MovMatrixOpGenericAdaptorBase(MovMatrixOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::LdStMatrixShapeAttr MovMatrixOpGenericAdaptorBase::getShape() { auto attr = getShapeAttr(); return ::llvm::cast<::mlir::NVVM::LdStMatrixShapeAttr>(attr); } ::mlir::NVVM::MMALayoutAttr MovMatrixOpGenericAdaptorBase::getLayoutAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::MMALayoutAttr>(getProperties().layout); return attr; } ::mlir::NVVM::MMALayout MovMatrixOpGenericAdaptorBase::getLayout() { auto attr = getLayoutAttr(); return attr.getValue(); } ::mlir::NVVM::LdStMatrixEltType MovMatrixOpGenericAdaptorBase::getEltType() { auto attr = getEltTypeAttr(); return attr.getValue(); } } // namespace detail MovMatrixOpAdaptor::MovMatrixOpAdaptor(MovMatrixOp op) : MovMatrixOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MovMatrixOpAdaptor::verify(::mlir::Location loc) { auto tblgen_eltType = getProperties().eltType; (void)tblgen_eltType; if (!tblgen_eltType) return emitError(loc, "'nvvm.movmatrix' op requires attribute 'eltType'"); auto tblgen_layout = getProperties().layout; (void)tblgen_layout; auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitError(loc, "'nvvm.movmatrix' op requires attribute 'shape'"); if (tblgen_shape && !((::llvm::isa<::mlir::NVVM::LdStMatrixShapeAttr>(tblgen_shape)))) return emitError(loc, "'nvvm.movmatrix' op attribute 'shape' failed to satisfy constraint: Matrix shape for ldmatrix and stmatrix"); if (tblgen_layout && !((::llvm::isa<::mlir::NVVM::MMALayoutAttr>(tblgen_layout)))) return emitError(loc, "'nvvm.movmatrix' op attribute 'layout' failed to satisfy constraint: NVVM MMA layout"); if (tblgen_eltType && !((::llvm::isa<::mlir::NVVM::LdStMatrixEltTypeAttr>(tblgen_eltType)))) return emitError(loc, "'nvvm.movmatrix' op attribute 'eltType' failed to satisfy constraint: Element type for ldmatrix and stmatrix"); return ::mlir::success(); } ::llvm::LogicalResult MovMatrixOp::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.eltType; auto attr = dict.get("eltType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `eltType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.layout; auto attr = dict.get("layout"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `layout` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.shape; auto attr = dict.get("shape"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `shape` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MovMatrixOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.eltType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("eltType", propStorage)); } { const auto &propStorage = prop.layout; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("layout", propStorage)); } { const auto &propStorage = prop.shape; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("shape", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MovMatrixOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.eltType.getAsOpaquePointer()), llvm::hash_value(prop.layout.getAsOpaquePointer()), llvm::hash_value(prop.shape.getAsOpaquePointer())); } std::optional MovMatrixOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "eltType") return prop.eltType; if (name == "layout") return prop.layout; if (name == "shape") return prop.shape; return std::nullopt; } void MovMatrixOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "eltType") { prop.eltType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "layout") { prop.layout = ::llvm::dyn_cast_or_null>(value); return; } if (name == "shape") { prop.shape = ::llvm::dyn_cast_or_null>(value); return; } } void MovMatrixOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.eltType) attrs.append("eltType", prop.eltType); if (prop.layout) attrs.append("layout", prop.layout); if (prop.shape) attrs.append("shape", prop.shape); } ::llvm::LogicalResult MovMatrixOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getEltTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps36(attr, "eltType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getLayoutAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(attr, "layout", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getShapeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps35(attr, "shape", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MovMatrixOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.eltType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.layout))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.shape))) return ::mlir::failure(); return ::mlir::success(); } void MovMatrixOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.eltType); writer.writeOptionalAttribute(prop.layout); writer.writeAttribute(prop.shape); } ::mlir::NVVM::LdStMatrixShapeAttr MovMatrixOp::getShape() { auto attr = getShapeAttr(); return ::llvm::cast<::mlir::NVVM::LdStMatrixShapeAttr>(attr); } ::mlir::NVVM::MMALayout MovMatrixOp::getLayout() { auto attr = getLayoutAttr(); return attr.getValue(); } ::mlir::NVVM::LdStMatrixEltType MovMatrixOp::getEltType() { auto attr = getEltTypeAttr(); return attr.getValue(); } void MovMatrixOp::setLayout(::mlir::NVVM::MMALayout attrValue) { getProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MovMatrixOp::setEltType(::mlir::NVVM::LdStMatrixEltType attrValue) { getProperties().eltType = ::mlir::NVVM::LdStMatrixEltTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MovMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { odsState.addOperands(src); odsState.getOrAddProperties().shape = shape; if (layout) { odsState.getOrAddProperties().layout = layout; } odsState.getOrAddProperties().eltType = eltType; odsState.addTypes(dst); } MovMatrixOp MovMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(shape), std::forward(layout), std::forward(eltType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MovMatrixOp MovMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(shape), std::forward(layout), std::forward(eltType)); } void MovMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { odsState.addOperands(src); odsState.getOrAddProperties().shape = shape; if (layout) { odsState.getOrAddProperties().layout = layout; } odsState.getOrAddProperties().eltType = eltType; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MovMatrixOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MovMatrixOp MovMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(shape), std::forward(layout), std::forward(eltType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MovMatrixOp MovMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { return create(builder, builder.getLoc(), std::forward(src), std::forward(shape), std::forward(layout), std::forward(eltType)); } void MovMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { odsState.addOperands(src); odsState.getOrAddProperties().shape = shape; if (layout) { odsState.getOrAddProperties().layout = layout; } odsState.getOrAddProperties().eltType = eltType; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MovMatrixOp MovMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(shape), std::forward(layout), std::forward(eltType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MovMatrixOp MovMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(shape), std::forward(layout), std::forward(eltType)); } void MovMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixEltType eltType) { odsState.addOperands(src); odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layout); odsState.getOrAddProperties().eltType = ::mlir::NVVM::LdStMatrixEltTypeAttr::get(odsBuilder.getContext(), eltType); odsState.addTypes(dst); } MovMatrixOp MovMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dst, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixEltType eltType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dst), std::forward(src), std::forward(shape), std::forward(layout), std::forward(eltType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MovMatrixOp MovMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dst, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixEltType eltType) { return create(builder, builder.getLoc(), std::forward(dst), std::forward(src), std::forward(shape), std::forward(layout), std::forward(eltType)); } void MovMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixEltType eltType) { odsState.addOperands(src); odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layout); odsState.getOrAddProperties().eltType = ::mlir::NVVM::LdStMatrixEltTypeAttr::get(odsBuilder.getContext(), eltType); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MovMatrixOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } MovMatrixOp MovMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixEltType eltType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(shape), std::forward(layout), std::forward(eltType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MovMatrixOp MovMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixEltType eltType) { return create(builder, builder.getLoc(), std::forward(src), std::forward(shape), std::forward(layout), std::forward(eltType)); } void MovMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixEltType eltType) { odsState.addOperands(src); odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layout); odsState.getOrAddProperties().eltType = ::mlir::NVVM::LdStMatrixEltTypeAttr::get(odsBuilder.getContext(), eltType); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MovMatrixOp MovMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixEltType eltType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(shape), std::forward(layout), std::forward(eltType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MovMatrixOp MovMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixEltType eltType) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(shape), std::forward(layout), std::forward(eltType)); } void MovMatrixOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } MovMatrixOp MovMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MovMatrixOp MovMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MovMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MovMatrixOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MovMatrixOp MovMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MovMatrixOp MovMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MovMatrixOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MovMatrixOp MovMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MovMatrixOp MovMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MovMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MovMatrixOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } MovMatrixOp MovMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MovMatrixOp MovMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void MovMatrixOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.layout) properties.layout = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), MMALayout::col); } ::llvm::LogicalResult MovMatrixOp::verifyInvariantsImpl() { auto tblgen_eltType = getProperties().eltType; (void)tblgen_eltType; if (!tblgen_eltType) return emitOpError("requires attribute 'eltType'"); auto tblgen_layout = getProperties().layout; (void)tblgen_layout; auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitOpError("requires attribute 'shape'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps35(*this, tblgen_shape, "shape"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(*this, tblgen_layout, "layout"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps36(*this, tblgen_eltType, "eltType"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MovMatrixOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult MovMatrixOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult MovMatrixOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) 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(); srcRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); result.addTypes(odsBuildableType0); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MovMatrixOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getLayoutAttr(); if(attr && (attr == ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), MMALayout::col))) elidedAttrs.push_back("layout"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::MovMatrixOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::MovMatrixOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::NanosleepOp definitions //===----------------------------------------------------------------------===// namespace detail { NanosleepOpGenericAdaptorBase::NanosleepOpGenericAdaptorBase(NanosleepOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail NanosleepOpAdaptor::NanosleepOpAdaptor(NanosleepOp op) : NanosleepOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult NanosleepOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult NanosleepOp::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 NanosleepOp::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 NanosleepOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional NanosleepOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void NanosleepOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void NanosleepOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult NanosleepOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void NanosleepOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value duration) { odsState.addOperands(duration); } NanosleepOp NanosleepOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value duration) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(duration)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NanosleepOp NanosleepOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value duration) { return create(builder, builder.getLoc(), std::forward(duration)); } void NanosleepOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value duration) { odsState.addOperands(duration); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } NanosleepOp NanosleepOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value duration) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(duration)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NanosleepOp NanosleepOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value duration) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(duration)); } void NanosleepOp::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); } NanosleepOp NanosleepOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NanosleepOp NanosleepOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void NanosleepOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } NanosleepOp NanosleepOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NanosleepOp NanosleepOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult NanosleepOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult NanosleepOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult NanosleepOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand durationRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> durationOperands(&durationRawOperand, 1); ::llvm::SMLoc durationOperandsLoc; (void)durationOperandsLoc; { 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(); } durationOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(durationRawOperand)) return ::mlir::failure(); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); if (parser.resolveOperands(durationOperands, odsBuildableType0, durationOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void NanosleepOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' '; _odsPrinter << getDuration(); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::NanosleepOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::PMEventOp definitions //===----------------------------------------------------------------------===// namespace detail { PMEventOpGenericAdaptorBase::PMEventOpGenericAdaptorBase(PMEventOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional PMEventOpGenericAdaptorBase::getMaskedEventId() { auto attr = getMaskedEventIdAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } ::std::optional PMEventOpGenericAdaptorBase::getEventId() { auto attr = getEventIdAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } } // namespace detail PMEventOpAdaptor::PMEventOpAdaptor(PMEventOp op) : PMEventOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult PMEventOpAdaptor::verify(::mlir::Location loc) { auto tblgen_eventId = getProperties().eventId; (void)tblgen_eventId; auto tblgen_maskedEventId = getProperties().maskedEventId; (void)tblgen_maskedEventId; if (tblgen_maskedEventId && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_maskedEventId))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_maskedEventId).getType().isSignlessInteger(16))))) return emitError(loc, "'nvvm.pmevent' op attribute 'maskedEventId' failed to satisfy constraint: 16-bit signless integer attribute"); if (tblgen_eventId && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_eventId))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_eventId).getType().isSignlessInteger(32))))) return emitError(loc, "'nvvm.pmevent' op attribute 'eventId' failed to satisfy constraint: 32-bit signless integer attribute"); return ::mlir::success(); } ::llvm::LogicalResult PMEventOp::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.eventId; auto attr = dict.get("eventId"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `eventId` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.maskedEventId; auto attr = dict.get("maskedEventId"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `maskedEventId` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute PMEventOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.eventId; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("eventId", propStorage)); } { const auto &propStorage = prop.maskedEventId; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("maskedEventId", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code PMEventOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.eventId.getAsOpaquePointer()), llvm::hash_value(prop.maskedEventId.getAsOpaquePointer())); } std::optional PMEventOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "eventId") return prop.eventId; if (name == "maskedEventId") return prop.maskedEventId; return std::nullopt; } void PMEventOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "eventId") { prop.eventId = ::llvm::dyn_cast_or_null>(value); return; } if (name == "maskedEventId") { prop.maskedEventId = ::llvm::dyn_cast_or_null>(value); return; } } void PMEventOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.eventId) attrs.append("eventId", prop.eventId); if (prop.maskedEventId) attrs.append("maskedEventId", prop.maskedEventId); } ::llvm::LogicalResult PMEventOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getEventIdAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(attr, "eventId", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getMaskedEventIdAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps46(attr, "maskedEventId", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult PMEventOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.eventId))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.maskedEventId))) return ::mlir::failure(); return ::mlir::success(); } void PMEventOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.eventId); writer.writeOptionalAttribute(prop.maskedEventId); } ::std::optional PMEventOp::getMaskedEventId() { auto attr = getMaskedEventIdAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } ::std::optional PMEventOp::getEventId() { auto attr = getEventIdAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } void PMEventOp::setMaskedEventId(::std::optional attrValue) { auto &odsProp = getProperties().maskedEventId; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(16), *attrValue); else odsProp = nullptr; } void PMEventOp::setEventId(::std::optional attrValue) { auto &odsProp = getProperties().eventId; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), *attrValue); else odsProp = nullptr; } void PMEventOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::IntegerAttr maskedEventId, /*optional*/::mlir::IntegerAttr eventId) { if (maskedEventId) { odsState.getOrAddProperties().maskedEventId = maskedEventId; } if (eventId) { odsState.getOrAddProperties().eventId = eventId; } } PMEventOp PMEventOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::IntegerAttr maskedEventId, /*optional*/::mlir::IntegerAttr eventId) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(maskedEventId), std::forward(eventId)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PMEventOp PMEventOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::IntegerAttr maskedEventId, /*optional*/::mlir::IntegerAttr eventId) { return create(builder, builder.getLoc(), std::forward(maskedEventId), std::forward(eventId)); } void PMEventOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::IntegerAttr maskedEventId, /*optional*/::mlir::IntegerAttr eventId) { if (maskedEventId) { odsState.getOrAddProperties().maskedEventId = maskedEventId; } if (eventId) { odsState.getOrAddProperties().eventId = eventId; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } PMEventOp PMEventOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::IntegerAttr maskedEventId, /*optional*/::mlir::IntegerAttr eventId) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(maskedEventId), std::forward(eventId)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PMEventOp PMEventOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::IntegerAttr maskedEventId, /*optional*/::mlir::IntegerAttr eventId) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(maskedEventId), std::forward(eventId)); } void PMEventOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } PMEventOp PMEventOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PMEventOp PMEventOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void PMEventOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } PMEventOp PMEventOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PMEventOp PMEventOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult PMEventOp::verifyInvariantsImpl() { auto tblgen_eventId = getProperties().eventId; (void)tblgen_eventId; auto tblgen_maskedEventId = getProperties().maskedEventId; (void)tblgen_maskedEventId; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps46(*this, tblgen_maskedEventId, "maskedEventId"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(*this, tblgen_eventId, "eventId"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult PMEventOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult PMEventOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::IntegerAttr eventIdAttr; ::mlir::IntegerAttr maskedEventIdAttr; { 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 (::mlir::succeeded(parser.parseOptionalKeyword("id"))) { if (parser.parseEqual()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(eventIdAttr, parser.getBuilder().getIntegerType(32))) { return ::mlir::failure(); } if (eventIdAttr) result.getOrAddProperties().eventId = eventIdAttr; } if (::mlir::succeeded(parser.parseOptionalKeyword("mask"))) { if (parser.parseEqual()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(maskedEventIdAttr, parser.getBuilder().getIntegerType(16))) { return ::mlir::failure(); } if (maskedEventIdAttr) result.getOrAddProperties().maskedEventId = maskedEventIdAttr; } return ::mlir::success(); } void PMEventOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("eventId"); elidedAttrs.push_back("maskedEventId"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); if (getEventIdAttr()) { _odsPrinter << ' ' << "id"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getEventIdAttr()); } if (getMaskedEventIdAttr()) { _odsPrinter << ' ' << "mask"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getMaskedEventIdAttr()); } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::PMEventOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::PMEventOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::PermuteOp definitions //===----------------------------------------------------------------------===// namespace detail { PermuteOpGenericAdaptorBase::PermuteOpGenericAdaptorBase(PermuteOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair PermuteOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true, false}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::NVVM::PermuteMode PermuteOpGenericAdaptorBase::getMode() { auto attr = getModeAttr(); return attr.getValue(); } } // namespace detail PermuteOpAdaptor::PermuteOpAdaptor(PermuteOp op) : PermuteOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult PermuteOpAdaptor::verify(::mlir::Location loc) { auto tblgen_mode = getProperties().mode; (void)tblgen_mode; if (!tblgen_mode) return emitError(loc, "'nvvm.prmt' op requires attribute 'mode'"); if (tblgen_mode && !((::llvm::isa<::mlir::NVVM::PermuteModeAttr>(tblgen_mode)))) return emitError(loc, "'nvvm.prmt' op attribute 'mode' failed to satisfy constraint: NVVM permute mode"); return ::mlir::success(); } std::pair PermuteOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, true, false}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange PermuteOp::getHiMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult PermuteOp::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.mode; auto attr = dict.get("mode"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `mode` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute PermuteOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.mode; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("mode", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code PermuteOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.mode.getAsOpaquePointer())); } std::optional PermuteOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "mode") return prop.mode; return std::nullopt; } void PermuteOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "mode") { prop.mode = ::llvm::dyn_cast_or_null>(value); return; } } void PermuteOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.mode) attrs.append("mode", prop.mode); } ::llvm::LogicalResult PermuteOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getModeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps47(attr, "mode", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult PermuteOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.mode))) return ::mlir::failure(); return ::mlir::success(); } void PermuteOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.mode); } ::mlir::NVVM::PermuteMode PermuteOp::getMode() { auto attr = getModeAttr(); return attr.getValue(); } void PermuteOp::setMode(::mlir::NVVM::PermuteMode attrValue) { getProperties().mode = ::mlir::NVVM::PermuteModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void PermuteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteModeAttr mode) { odsState.addOperands(lo); if (hi) odsState.addOperands(hi); odsState.addOperands(selector); odsState.getOrAddProperties().mode = mode; odsState.addTypes(res); } PermuteOp PermuteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteModeAttr mode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(lo), std::forward(hi), std::forward(selector), std::forward(mode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PermuteOp PermuteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteModeAttr mode) { return create(builder, builder.getLoc(), std::forward(res), std::forward(lo), std::forward(hi), std::forward(selector), std::forward(mode)); } void PermuteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteModeAttr mode) { odsState.addOperands(lo); if (hi) odsState.addOperands(hi); odsState.addOperands(selector); odsState.getOrAddProperties().mode = mode; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(PermuteOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } PermuteOp PermuteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteModeAttr mode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lo), std::forward(hi), std::forward(selector), std::forward(mode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PermuteOp PermuteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteModeAttr mode) { return create(builder, builder.getLoc(), std::forward(lo), std::forward(hi), std::forward(selector), std::forward(mode)); } void PermuteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteModeAttr mode) { odsState.addOperands(lo); if (hi) odsState.addOperands(hi); odsState.addOperands(selector); odsState.getOrAddProperties().mode = mode; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } PermuteOp PermuteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteModeAttr mode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lo), std::forward(hi), std::forward(selector), std::forward(mode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PermuteOp PermuteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteModeAttr mode) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lo), std::forward(hi), std::forward(selector), std::forward(mode)); } void PermuteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteMode mode) { odsState.addOperands(lo); if (hi) odsState.addOperands(hi); odsState.addOperands(selector); odsState.getOrAddProperties().mode = ::mlir::NVVM::PermuteModeAttr::get(odsBuilder.getContext(), mode); odsState.addTypes(res); } PermuteOp PermuteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteMode mode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(lo), std::forward(hi), std::forward(selector), std::forward(mode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PermuteOp PermuteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteMode mode) { return create(builder, builder.getLoc(), std::forward(res), std::forward(lo), std::forward(hi), std::forward(selector), std::forward(mode)); } void PermuteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteMode mode) { odsState.addOperands(lo); if (hi) odsState.addOperands(hi); odsState.addOperands(selector); odsState.getOrAddProperties().mode = ::mlir::NVVM::PermuteModeAttr::get(odsBuilder.getContext(), mode); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(PermuteOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } PermuteOp PermuteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteMode mode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lo), std::forward(hi), std::forward(selector), std::forward(mode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PermuteOp PermuteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteMode mode) { return create(builder, builder.getLoc(), std::forward(lo), std::forward(hi), std::forward(selector), std::forward(mode)); } void PermuteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteMode mode) { odsState.addOperands(lo); if (hi) odsState.addOperands(hi); odsState.addOperands(selector); odsState.getOrAddProperties().mode = ::mlir::NVVM::PermuteModeAttr::get(odsBuilder.getContext(), mode); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } PermuteOp PermuteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteMode mode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lo), std::forward(hi), std::forward(selector), std::forward(mode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PermuteOp PermuteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lo, /*optional*/::mlir::Value hi, ::mlir::Value selector, ::mlir::NVVM::PermuteMode mode) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lo), std::forward(hi), std::forward(selector), std::forward(mode)); } void PermuteOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } PermuteOp PermuteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PermuteOp PermuteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void PermuteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(PermuteOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } PermuteOp PermuteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PermuteOp PermuteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void PermuteOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } PermuteOp PermuteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PermuteOp PermuteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void PermuteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(PermuteOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } PermuteOp PermuteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PermuteOp PermuteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult PermuteOp::verifyInvariantsImpl() { auto tblgen_mode = getProperties().mode; (void)tblgen_mode; if (!tblgen_mode) return emitOpError("requires attribute 'mode'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps47(*this, tblgen_mode, "mode"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult PermuteOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult PermuteOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult PermuteOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::PermuteModeAttr modeAttr; ::mlir::OpAsmParser::UnresolvedOperand selectorRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> selectorOperands(&selectorRawOperand, 1); ::llvm::SMLoc selectorOperandsLoc; (void)selectorOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand loRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> loOperands(&loRawOperand, 1); ::llvm::SMLoc loOperandsLoc; (void)loOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> hiOperands; ::llvm::SMLoc hiOperandsLoc; (void)hiOperandsLoc; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (parser.parseCustomAttributeWithFallback(modeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (modeAttr) result.getOrAddProperties().mode = modeAttr; selectorOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(selectorRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); loOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(loRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { hiOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); hiOperands.push_back(operand); } } } { 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(); resRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); result.addTypes(resTypes); if (parser.resolveOperands(loOperands, odsBuildableType0, loOperandsLoc, result.operands)) return ::mlir::failure(); if (!hiOperands.empty()) { if (parser.resolveOperands(hiOperands, odsBuildableType0, hiOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(selectorOperands, odsBuildableType0, selectorOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void PermuteOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getModeAttr()); _odsPrinter << ' '; _odsPrinter << getSelector(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getLo(); if (getHi()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getHi()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("mode"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void PermuteOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::PermuteOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::PermuteOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::PrefetchOp definitions //===----------------------------------------------------------------------===// namespace detail { PrefetchOpGenericAdaptorBase::PrefetchOpGenericAdaptorBase(PrefetchOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair PrefetchOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::std::optional<::mlir::NVVM::PrefetchCacheLevel> PrefetchOpGenericAdaptorBase::getCacheLevel() { auto attr = getCacheLevelAttr(); return attr ? ::std::optional<::mlir::NVVM::PrefetchCacheLevel>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::NVVM::CacheEvictionPriority> PrefetchOpGenericAdaptorBase::getEvictPriority() { auto attr = getEvictPriorityAttr(); return attr ? ::std::optional<::mlir::NVVM::CacheEvictionPriority>(attr.getValue()) : (::std::nullopt); } ::mlir::UnitAttr PrefetchOpGenericAdaptorBase::getTensormapAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().tensormap); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool PrefetchOpGenericAdaptorBase::getTensormap() { auto attr = getTensormapAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::mlir::UnitAttr PrefetchOpGenericAdaptorBase::getUniformAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().uniform); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool PrefetchOpGenericAdaptorBase::getUniform() { auto attr = getUniformAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::mlir::UnitAttr PrefetchOpGenericAdaptorBase::getInParamSpaceAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().in_param_space); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool PrefetchOpGenericAdaptorBase::getInParamSpace() { auto attr = getInParamSpaceAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail PrefetchOpAdaptor::PrefetchOpAdaptor(PrefetchOp op) : PrefetchOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult PrefetchOpAdaptor::verify(::mlir::Location loc) { auto tblgen_cacheLevel = getProperties().cacheLevel; (void)tblgen_cacheLevel; auto tblgen_evictPriority = getProperties().evictPriority; (void)tblgen_evictPriority; auto tblgen_in_param_space = getProperties().in_param_space; (void)tblgen_in_param_space; auto tblgen_tensormap = getProperties().tensormap; (void)tblgen_tensormap; auto tblgen_uniform = getProperties().uniform; (void)tblgen_uniform; if (tblgen_cacheLevel && !((::llvm::isa<::mlir::NVVM::PrefetchCacheLevelAttr>(tblgen_cacheLevel)))) return emitError(loc, "'nvvm.prefetch' op attribute 'cacheLevel' failed to satisfy constraint: NVVM Prefetch Cache Level"); if (tblgen_evictPriority && !((::llvm::isa<::mlir::NVVM::CacheEvictionPriorityAttr>(tblgen_evictPriority)))) return emitError(loc, "'nvvm.prefetch' op attribute 'evictPriority' failed to satisfy constraint: NVVM Cache Eviction Priority"); if (tblgen_tensormap && !((::llvm::isa<::mlir::UnitAttr>(tblgen_tensormap)))) return emitError(loc, "'nvvm.prefetch' op attribute 'tensormap' failed to satisfy constraint: unit attribute"); if (tblgen_uniform && !((::llvm::isa<::mlir::UnitAttr>(tblgen_uniform)))) return emitError(loc, "'nvvm.prefetch' op attribute 'uniform' failed to satisfy constraint: unit attribute"); if (tblgen_in_param_space && !((::llvm::isa<::mlir::UnitAttr>(tblgen_in_param_space)))) return emitError(loc, "'nvvm.prefetch' op attribute 'in_param_space' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } std::pair PrefetchOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange PrefetchOp::getPredicateMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult PrefetchOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.cacheLevel; auto attr = dict.get("cacheLevel"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `cacheLevel` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.evictPriority; auto attr = dict.get("evictPriority"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `evictPriority` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.in_param_space; auto attr = dict.get("in_param_space"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `in_param_space` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.tensormap; auto attr = dict.get("tensormap"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `tensormap` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.uniform; auto attr = dict.get("uniform"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `uniform` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute PrefetchOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.cacheLevel; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("cacheLevel", propStorage)); } { const auto &propStorage = prop.evictPriority; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("evictPriority", propStorage)); } { const auto &propStorage = prop.in_param_space; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("in_param_space", propStorage)); } { const auto &propStorage = prop.tensormap; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("tensormap", propStorage)); } { const auto &propStorage = prop.uniform; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("uniform", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code PrefetchOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.cacheLevel.getAsOpaquePointer()), llvm::hash_value(prop.evictPriority.getAsOpaquePointer()), llvm::hash_value(prop.in_param_space.getAsOpaquePointer()), llvm::hash_value(prop.tensormap.getAsOpaquePointer()), llvm::hash_value(prop.uniform.getAsOpaquePointer())); } std::optional PrefetchOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "cacheLevel") return prop.cacheLevel; if (name == "evictPriority") return prop.evictPriority; if (name == "in_param_space") return prop.in_param_space; if (name == "tensormap") return prop.tensormap; if (name == "uniform") return prop.uniform; return std::nullopt; } void PrefetchOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "cacheLevel") { prop.cacheLevel = ::llvm::dyn_cast_or_null>(value); return; } if (name == "evictPriority") { prop.evictPriority = ::llvm::dyn_cast_or_null>(value); return; } if (name == "in_param_space") { prop.in_param_space = ::llvm::dyn_cast_or_null>(value); return; } if (name == "tensormap") { prop.tensormap = ::llvm::dyn_cast_or_null>(value); return; } if (name == "uniform") { prop.uniform = ::llvm::dyn_cast_or_null>(value); return; } } void PrefetchOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.cacheLevel) attrs.append("cacheLevel", prop.cacheLevel); if (prop.evictPriority) attrs.append("evictPriority", prop.evictPriority); if (prop.in_param_space) attrs.append("in_param_space", prop.in_param_space); if (prop.tensormap) attrs.append("tensormap", prop.tensormap); if (prop.uniform) attrs.append("uniform", prop.uniform); } ::llvm::LogicalResult PrefetchOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getCacheLevelAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps48(attr, "cacheLevel", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getEvictPriorityAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps49(attr, "evictPriority", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getInParamSpaceAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "in_param_space", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getTensormapAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "tensormap", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getUniformAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "uniform", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult PrefetchOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.cacheLevel))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.evictPriority))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.in_param_space))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.tensormap))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.uniform))) return ::mlir::failure(); return ::mlir::success(); } void PrefetchOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.cacheLevel); writer.writeOptionalAttribute(prop.evictPriority); writer.writeOptionalAttribute(prop.in_param_space); writer.writeOptionalAttribute(prop.tensormap); writer.writeOptionalAttribute(prop.uniform); } ::std::optional<::mlir::NVVM::PrefetchCacheLevel> PrefetchOp::getCacheLevel() { auto attr = getCacheLevelAttr(); return attr ? ::std::optional<::mlir::NVVM::PrefetchCacheLevel>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::NVVM::CacheEvictionPriority> PrefetchOp::getEvictPriority() { auto attr = getEvictPriorityAttr(); return attr ? ::std::optional<::mlir::NVVM::CacheEvictionPriority>(attr.getValue()) : (::std::nullopt); } bool PrefetchOp::getTensormap() { auto attr = getTensormapAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } bool PrefetchOp::getUniform() { auto attr = getUniformAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } bool PrefetchOp::getInParamSpace() { auto attr = getInParamSpaceAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void PrefetchOp::setCacheLevel(::std::optional<::mlir::NVVM::PrefetchCacheLevel> attrValue) { auto &odsProp = getProperties().cacheLevel; if (attrValue) odsProp = ::mlir::NVVM::PrefetchCacheLevelAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void PrefetchOp::setEvictPriority(::std::optional<::mlir::NVVM::CacheEvictionPriority> attrValue) { auto &odsProp = getProperties().evictPriority; if (attrValue) odsProp = ::mlir::NVVM::CacheEvictionPriorityAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void PrefetchOp::setTensormap(bool attrValue) { auto &odsProp = getProperties().tensormap; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void PrefetchOp::setUniform(bool attrValue) { auto &odsProp = getProperties().uniform; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void PrefetchOp::setInParamSpace(bool attrValue) { auto &odsProp = getProperties().in_param_space; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void PrefetchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::NVVM::PrefetchCacheLevelAttr cacheLevel, /*optional*/::mlir::NVVM::CacheEvictionPriorityAttr evictPriority, ::mlir::Value addr, /*optional*/::mlir::Value predicate, /*optional*/::mlir::UnitAttr tensormap, /*optional*/::mlir::UnitAttr uniform, /*optional*/::mlir::UnitAttr in_param_space) { odsState.addOperands(addr); if (predicate) odsState.addOperands(predicate); if (cacheLevel) { odsState.getOrAddProperties().cacheLevel = cacheLevel; } if (evictPriority) { odsState.getOrAddProperties().evictPriority = evictPriority; } if (tensormap) { odsState.getOrAddProperties().tensormap = tensormap; } if (uniform) { odsState.getOrAddProperties().uniform = uniform; } if (in_param_space) { odsState.getOrAddProperties().in_param_space = in_param_space; } } PrefetchOp PrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::NVVM::PrefetchCacheLevelAttr cacheLevel, /*optional*/::mlir::NVVM::CacheEvictionPriorityAttr evictPriority, ::mlir::Value addr, /*optional*/::mlir::Value predicate, /*optional*/::mlir::UnitAttr tensormap, /*optional*/::mlir::UnitAttr uniform, /*optional*/::mlir::UnitAttr in_param_space) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(cacheLevel), std::forward(evictPriority), std::forward(addr), std::forward(predicate), std::forward(tensormap), std::forward(uniform), std::forward(in_param_space)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrefetchOp PrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::NVVM::PrefetchCacheLevelAttr cacheLevel, /*optional*/::mlir::NVVM::CacheEvictionPriorityAttr evictPriority, ::mlir::Value addr, /*optional*/::mlir::Value predicate, /*optional*/::mlir::UnitAttr tensormap, /*optional*/::mlir::UnitAttr uniform, /*optional*/::mlir::UnitAttr in_param_space) { return create(builder, builder.getLoc(), std::forward(cacheLevel), std::forward(evictPriority), std::forward(addr), std::forward(predicate), std::forward(tensormap), std::forward(uniform), std::forward(in_param_space)); } void PrefetchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::NVVM::PrefetchCacheLevelAttr cacheLevel, /*optional*/::mlir::NVVM::CacheEvictionPriorityAttr evictPriority, ::mlir::Value addr, /*optional*/::mlir::Value predicate, /*optional*/::mlir::UnitAttr tensormap, /*optional*/::mlir::UnitAttr uniform, /*optional*/::mlir::UnitAttr in_param_space) { odsState.addOperands(addr); if (predicate) odsState.addOperands(predicate); if (cacheLevel) { odsState.getOrAddProperties().cacheLevel = cacheLevel; } if (evictPriority) { odsState.getOrAddProperties().evictPriority = evictPriority; } if (tensormap) { odsState.getOrAddProperties().tensormap = tensormap; } if (uniform) { odsState.getOrAddProperties().uniform = uniform; } if (in_param_space) { odsState.getOrAddProperties().in_param_space = in_param_space; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } PrefetchOp PrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::NVVM::PrefetchCacheLevelAttr cacheLevel, /*optional*/::mlir::NVVM::CacheEvictionPriorityAttr evictPriority, ::mlir::Value addr, /*optional*/::mlir::Value predicate, /*optional*/::mlir::UnitAttr tensormap, /*optional*/::mlir::UnitAttr uniform, /*optional*/::mlir::UnitAttr in_param_space) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(cacheLevel), std::forward(evictPriority), std::forward(addr), std::forward(predicate), std::forward(tensormap), std::forward(uniform), std::forward(in_param_space)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrefetchOp PrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::NVVM::PrefetchCacheLevelAttr cacheLevel, /*optional*/::mlir::NVVM::CacheEvictionPriorityAttr evictPriority, ::mlir::Value addr, /*optional*/::mlir::Value predicate, /*optional*/::mlir::UnitAttr tensormap, /*optional*/::mlir::UnitAttr uniform, /*optional*/::mlir::UnitAttr in_param_space) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(cacheLevel), std::forward(evictPriority), std::forward(addr), std::forward(predicate), std::forward(tensormap), std::forward(uniform), std::forward(in_param_space)); } void PrefetchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::NVVM::PrefetchCacheLevelAttr cacheLevel, /*optional*/::mlir::NVVM::CacheEvictionPriorityAttr evictPriority, ::mlir::Value addr, /*optional*/::mlir::Value predicate, /*optional*/bool tensormap, /*optional*/bool uniform, /*optional*/bool in_param_space) { odsState.addOperands(addr); if (predicate) odsState.addOperands(predicate); if (cacheLevel) { odsState.getOrAddProperties().cacheLevel = cacheLevel; } if (evictPriority) { odsState.getOrAddProperties().evictPriority = evictPriority; } if (tensormap) { odsState.getOrAddProperties().tensormap = ((tensormap) ? odsBuilder.getUnitAttr() : nullptr); } if (uniform) { odsState.getOrAddProperties().uniform = ((uniform) ? odsBuilder.getUnitAttr() : nullptr); } if (in_param_space) { odsState.getOrAddProperties().in_param_space = ((in_param_space) ? odsBuilder.getUnitAttr() : nullptr); } } PrefetchOp PrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::NVVM::PrefetchCacheLevelAttr cacheLevel, /*optional*/::mlir::NVVM::CacheEvictionPriorityAttr evictPriority, ::mlir::Value addr, /*optional*/::mlir::Value predicate, /*optional*/bool tensormap, /*optional*/bool uniform, /*optional*/bool in_param_space) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(cacheLevel), std::forward(evictPriority), std::forward(addr), std::forward(predicate), std::forward(tensormap), std::forward(uniform), std::forward(in_param_space)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrefetchOp PrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::NVVM::PrefetchCacheLevelAttr cacheLevel, /*optional*/::mlir::NVVM::CacheEvictionPriorityAttr evictPriority, ::mlir::Value addr, /*optional*/::mlir::Value predicate, /*optional*/bool tensormap, /*optional*/bool uniform, /*optional*/bool in_param_space) { return create(builder, builder.getLoc(), std::forward(cacheLevel), std::forward(evictPriority), std::forward(addr), std::forward(predicate), std::forward(tensormap), std::forward(uniform), std::forward(in_param_space)); } void PrefetchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::NVVM::PrefetchCacheLevelAttr cacheLevel, /*optional*/::mlir::NVVM::CacheEvictionPriorityAttr evictPriority, ::mlir::Value addr, /*optional*/::mlir::Value predicate, /*optional*/bool tensormap, /*optional*/bool uniform, /*optional*/bool in_param_space) { odsState.addOperands(addr); if (predicate) odsState.addOperands(predicate); if (cacheLevel) { odsState.getOrAddProperties().cacheLevel = cacheLevel; } if (evictPriority) { odsState.getOrAddProperties().evictPriority = evictPriority; } if (tensormap) { odsState.getOrAddProperties().tensormap = ((tensormap) ? odsBuilder.getUnitAttr() : nullptr); } if (uniform) { odsState.getOrAddProperties().uniform = ((uniform) ? odsBuilder.getUnitAttr() : nullptr); } if (in_param_space) { odsState.getOrAddProperties().in_param_space = ((in_param_space) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } PrefetchOp PrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::NVVM::PrefetchCacheLevelAttr cacheLevel, /*optional*/::mlir::NVVM::CacheEvictionPriorityAttr evictPriority, ::mlir::Value addr, /*optional*/::mlir::Value predicate, /*optional*/bool tensormap, /*optional*/bool uniform, /*optional*/bool in_param_space) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(cacheLevel), std::forward(evictPriority), std::forward(addr), std::forward(predicate), std::forward(tensormap), std::forward(uniform), std::forward(in_param_space)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrefetchOp PrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::NVVM::PrefetchCacheLevelAttr cacheLevel, /*optional*/::mlir::NVVM::CacheEvictionPriorityAttr evictPriority, ::mlir::Value addr, /*optional*/::mlir::Value predicate, /*optional*/bool tensormap, /*optional*/bool uniform, /*optional*/bool in_param_space) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(cacheLevel), std::forward(evictPriority), std::forward(addr), std::forward(predicate), std::forward(tensormap), std::forward(uniform), std::forward(in_param_space)); } void PrefetchOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } PrefetchOp PrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrefetchOp PrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void PrefetchOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } PrefetchOp PrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrefetchOp PrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult PrefetchOp::verifyInvariantsImpl() { auto tblgen_cacheLevel = getProperties().cacheLevel; (void)tblgen_cacheLevel; auto tblgen_evictPriority = getProperties().evictPriority; (void)tblgen_evictPriority; auto tblgen_in_param_space = getProperties().in_param_space; (void)tblgen_in_param_space; auto tblgen_tensormap = getProperties().tensormap; (void)tblgen_tensormap; auto tblgen_uniform = getProperties().uniform; (void)tblgen_uniform; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps48(*this, tblgen_cacheLevel, "cacheLevel"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps49(*this, tblgen_evictPriority, "evictPriority"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_tensormap, "tensormap"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_uniform, "uniform"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_in_param_space, "in_param_space"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps36(*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_NVVMOps23(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult PrefetchOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult PrefetchOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::PrefetchCacheLevelAttr cacheLevelAttr; ::mlir::NVVM::CacheEvictionPriorityAttr evictPriorityAttr; ::mlir::OpAsmParser::UnresolvedOperand addrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> addrOperands(&addrRawOperand, 1); ::llvm::SMLoc addrOperandsLoc; (void)addrOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> predicateOperands; ::llvm::SMLoc predicateOperandsLoc; (void)predicateOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; if (::mlir::succeeded(parser.parseOptionalKeyword("level"))) { if (parser.parseEqual()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(cacheLevelAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (cacheLevelAttr) result.getOrAddProperties().cacheLevel = cacheLevelAttr; if (::mlir::succeeded(parser.parseOptionalKeyword("uniform"))) { result.getOrAddProperties().uniform = parser.getBuilder().getUnitAttr(); } if (parser.parseComma()) return ::mlir::failure(); } if (::mlir::succeeded(parser.parseOptionalKeyword("tensormap"))) { result.getOrAddProperties().tensormap = parser.getBuilder().getUnitAttr(); if (::mlir::succeeded(parser.parseOptionalKeyword("in_param_space"))) { result.getOrAddProperties().in_param_space = parser.getBuilder().getUnitAttr(); } if (parser.parseComma()) return ::mlir::failure(); } if (::mlir::succeeded(parser.parseOptionalKeyword("evict_priority"))) { if (parser.parseEqual()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(evictPriorityAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (evictPriorityAttr) result.getOrAddProperties().evictPriority = evictPriorityAttr; if (parser.parseComma()) return ::mlir::failure(); } addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { if (parser.parseKeyword("predicate")) return ::mlir::failure(); if (parser.parseEqual()) return ::mlir::failure(); { predicateOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); predicateOperands.push_back(operand); } } } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.resolveOperands(::llvm::concat(addrOperands, predicateOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void PrefetchOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getCacheLevelAttr()) { _odsPrinter << ' ' << "level"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getCacheLevelAttr()); if ((getUniformAttr() && getUniformAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "uniform"; } _odsPrinter << ","; } if ((getTensormapAttr() && getTensormapAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "tensormap"; if ((getInParamSpaceAttr() && getInParamSpaceAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "in_param_space"; } _odsPrinter << ","; } if (getEvictPriorityAttr()) { _odsPrinter << ' ' << "evict_priority"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getEvictPriorityAttr()); _odsPrinter << ","; } _odsPrinter << ' '; _odsPrinter << getAddr(); if (getPredicate()) { _odsPrinter << ","; _odsPrinter << ' ' << "predicate"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getPredicate()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("cacheLevel"); elidedAttrs.push_back("uniform"); elidedAttrs.push_back("tensormap"); elidedAttrs.push_back("in_param_space"); elidedAttrs.push_back("evictPriority"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getTensormapAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("tensormap"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getUniformAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("uniform"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getInParamSpaceAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("in_param_space"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); } std::string PrefetchOp::getPtx() { // Inline PTX is only supported for prefetch tensormap return std::string("prefetch.tensormap [%0];"); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::PrefetchOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::PrefetchOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::RcpApproxFtzF32Op definitions //===----------------------------------------------------------------------===// namespace detail { RcpApproxFtzF32OpGenericAdaptorBase::RcpApproxFtzF32OpGenericAdaptorBase(RcpApproxFtzF32Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail RcpApproxFtzF32OpAdaptor::RcpApproxFtzF32OpAdaptor(RcpApproxFtzF32Op op) : RcpApproxFtzF32OpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult RcpApproxFtzF32OpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult RcpApproxFtzF32Op::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 RcpApproxFtzF32Op::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 RcpApproxFtzF32Op::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional RcpApproxFtzF32Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void RcpApproxFtzF32Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void RcpApproxFtzF32Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult RcpApproxFtzF32Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void RcpApproxFtzF32Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value arg) { odsState.addOperands(arg); odsState.addTypes(res); } RcpApproxFtzF32Op RcpApproxFtzF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value arg) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(arg)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RcpApproxFtzF32Op RcpApproxFtzF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value arg) { return create(builder, builder.getLoc(), std::forward(res), std::forward(arg)); } void RcpApproxFtzF32Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arg) { odsState.addOperands(arg); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(RcpApproxFtzF32Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } RcpApproxFtzF32Op RcpApproxFtzF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value arg) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(arg)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RcpApproxFtzF32Op RcpApproxFtzF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value arg) { return create(builder, builder.getLoc(), std::forward(arg)); } void RcpApproxFtzF32Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arg) { odsState.addOperands(arg); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } RcpApproxFtzF32Op RcpApproxFtzF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value arg) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(arg)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RcpApproxFtzF32Op RcpApproxFtzF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value arg) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(arg)); } void RcpApproxFtzF32Op::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); } RcpApproxFtzF32Op RcpApproxFtzF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RcpApproxFtzF32Op RcpApproxFtzF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void RcpApproxFtzF32Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(RcpApproxFtzF32Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } RcpApproxFtzF32Op RcpApproxFtzF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RcpApproxFtzF32Op RcpApproxFtzF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void RcpApproxFtzF32Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } RcpApproxFtzF32Op RcpApproxFtzF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RcpApproxFtzF32Op RcpApproxFtzF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void RcpApproxFtzF32Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(RcpApproxFtzF32Op::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } RcpApproxFtzF32Op RcpApproxFtzF32Op::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RcpApproxFtzF32Op RcpApproxFtzF32Op::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult RcpApproxFtzF32Op::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*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_NVVMOps13(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult RcpApproxFtzF32Op::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult RcpApproxFtzF32Op::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getF32Type(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult RcpApproxFtzF32Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand argRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> argOperands(&argRawOperand, 1); ::llvm::SMLoc argOperandsLoc; (void)argOperandsLoc; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); argOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(argRawOperand)) 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::FloatType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getF32Type(); result.addTypes(resTypes); if (parser.resolveOperands(argOperands, odsBuildableType0, argOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void RcpApproxFtzF32Op::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getArg(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::FloatType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void RcpApproxFtzF32Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::RcpApproxFtzF32Op) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ReduxOp definitions //===----------------------------------------------------------------------===// namespace detail { ReduxOpGenericAdaptorBase::ReduxOpGenericAdaptorBase(ReduxOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::ReductionKind ReduxOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::mlir::BoolAttr ReduxOpGenericAdaptorBase::getAbsAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().abs); return attr; } bool ReduxOpGenericAdaptorBase::getAbs() { auto attr = getAbsAttr(); return attr.getValue(); } ::mlir::BoolAttr ReduxOpGenericAdaptorBase::getNanAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().nan); return attr; } bool ReduxOpGenericAdaptorBase::getNan() { auto attr = getNanAttr(); return attr.getValue(); } } // namespace detail ReduxOpAdaptor::ReduxOpAdaptor(ReduxOp op) : ReduxOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ReduxOpAdaptor::verify(::mlir::Location loc) { auto tblgen_abs = getProperties().abs; (void)tblgen_abs; auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'nvvm.redux.sync' op requires attribute 'kind'"); auto tblgen_nan = getProperties().nan; (void)tblgen_nan; if (tblgen_kind && !((::llvm::isa<::mlir::NVVM::ReductionKindAttr>(tblgen_kind)))) return emitError(loc, "'nvvm.redux.sync' op attribute 'kind' failed to satisfy constraint: NVVM Reduction Kind attribute"); if (tblgen_abs && !((::llvm::isa<::mlir::BoolAttr>(tblgen_abs)))) return emitError(loc, "'nvvm.redux.sync' op attribute 'abs' failed to satisfy constraint: bool attribute"); if (tblgen_nan && !((::llvm::isa<::mlir::BoolAttr>(tblgen_nan)))) return emitError(loc, "'nvvm.redux.sync' op attribute 'nan' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult ReduxOp::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.abs; auto attr = dict.get("abs"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `abs` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.nan; auto attr = dict.get("nan"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `nan` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ReduxOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.abs; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("abs", propStorage)); } { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", propStorage)); } { const auto &propStorage = prop.nan; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("nan", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ReduxOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.abs.getAsOpaquePointer()), llvm::hash_value(prop.kind.getAsOpaquePointer()), llvm::hash_value(prop.nan.getAsOpaquePointer())); } std::optional ReduxOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "abs") return prop.abs; if (name == "kind") return prop.kind; if (name == "nan") return prop.nan; return std::nullopt; } void ReduxOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "abs") { prop.abs = ::llvm::dyn_cast_or_null>(value); return; } if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } if (name == "nan") { prop.nan = ::llvm::dyn_cast_or_null>(value); return; } } void ReduxOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.abs) attrs.append("abs", prop.abs); if (prop.kind) attrs.append("kind", prop.kind); if (prop.nan) attrs.append("nan", prop.nan); } ::llvm::LogicalResult ReduxOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAbsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "abs", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps50(attr, "kind", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNanAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "nan", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ReduxOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.abs))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.kind))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.nan))) return ::mlir::failure(); return ::mlir::success(); } void ReduxOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.abs); writer.writeAttribute(prop.kind); writer.writeOptionalAttribute(prop.nan); } ::mlir::NVVM::ReductionKind ReduxOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } bool ReduxOp::getAbs() { auto attr = getAbsAttr(); return attr.getValue(); } bool ReduxOp::getNan() { auto attr = getNanAttr(); return attr.getValue(); } void ReduxOp::setKind(::mlir::NVVM::ReductionKind attrValue) { getProperties().kind = ::mlir::NVVM::ReductionKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ReduxOp::setAbs(bool attrValue) { getProperties().abs = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ReduxOp::setNan(bool attrValue) { getProperties().nan = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ReduxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value val, ::mlir::NVVM::ReductionKindAttr kind, ::mlir::Value mask_and_clamp, ::mlir::BoolAttr abs, ::mlir::BoolAttr nan) { odsState.addOperands(val); odsState.addOperands(mask_and_clamp); odsState.getOrAddProperties().kind = kind; if (abs) { odsState.getOrAddProperties().abs = abs; } if (nan) { odsState.getOrAddProperties().nan = nan; } odsState.addTypes(res); } ReduxOp ReduxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value val, ::mlir::NVVM::ReductionKindAttr kind, ::mlir::Value mask_and_clamp, ::mlir::BoolAttr abs, ::mlir::BoolAttr nan) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(val), std::forward(kind), std::forward(mask_and_clamp), std::forward(abs), std::forward(nan)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReduxOp ReduxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value val, ::mlir::NVVM::ReductionKindAttr kind, ::mlir::Value mask_and_clamp, ::mlir::BoolAttr abs, ::mlir::BoolAttr nan) { return create(builder, builder.getLoc(), std::forward(res), std::forward(val), std::forward(kind), std::forward(mask_and_clamp), std::forward(abs), std::forward(nan)); } void ReduxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value val, ::mlir::NVVM::ReductionKindAttr kind, ::mlir::Value mask_and_clamp, ::mlir::BoolAttr abs, ::mlir::BoolAttr nan) { odsState.addOperands(val); odsState.addOperands(mask_and_clamp); odsState.getOrAddProperties().kind = kind; if (abs) { odsState.getOrAddProperties().abs = abs; } if (nan) { odsState.getOrAddProperties().nan = nan; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ReduxOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ReduxOp ReduxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value val, ::mlir::NVVM::ReductionKindAttr kind, ::mlir::Value mask_and_clamp, ::mlir::BoolAttr abs, ::mlir::BoolAttr nan) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(val), std::forward(kind), std::forward(mask_and_clamp), std::forward(abs), std::forward(nan)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReduxOp ReduxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value val, ::mlir::NVVM::ReductionKindAttr kind, ::mlir::Value mask_and_clamp, ::mlir::BoolAttr abs, ::mlir::BoolAttr nan) { return create(builder, builder.getLoc(), std::forward(val), std::forward(kind), std::forward(mask_and_clamp), std::forward(abs), std::forward(nan)); } void ReduxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value val, ::mlir::NVVM::ReductionKindAttr kind, ::mlir::Value mask_and_clamp, ::mlir::BoolAttr abs, ::mlir::BoolAttr nan) { odsState.addOperands(val); odsState.addOperands(mask_and_clamp); odsState.getOrAddProperties().kind = kind; if (abs) { odsState.getOrAddProperties().abs = abs; } if (nan) { odsState.getOrAddProperties().nan = nan; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReduxOp ReduxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value val, ::mlir::NVVM::ReductionKindAttr kind, ::mlir::Value mask_and_clamp, ::mlir::BoolAttr abs, ::mlir::BoolAttr nan) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(val), std::forward(kind), std::forward(mask_and_clamp), std::forward(abs), std::forward(nan)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReduxOp ReduxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value val, ::mlir::NVVM::ReductionKindAttr kind, ::mlir::Value mask_and_clamp, ::mlir::BoolAttr abs, ::mlir::BoolAttr nan) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(val), std::forward(kind), std::forward(mask_and_clamp), std::forward(abs), std::forward(nan)); } void ReduxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value val, ::mlir::NVVM::ReductionKind kind, ::mlir::Value mask_and_clamp, bool abs, bool nan) { odsState.addOperands(val); odsState.addOperands(mask_and_clamp); odsState.getOrAddProperties().kind = ::mlir::NVVM::ReductionKindAttr::get(odsBuilder.getContext(), kind); odsState.getOrAddProperties().abs = odsBuilder.getBoolAttr(abs); odsState.getOrAddProperties().nan = odsBuilder.getBoolAttr(nan); odsState.addTypes(res); } ReduxOp ReduxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value val, ::mlir::NVVM::ReductionKind kind, ::mlir::Value mask_and_clamp, bool abs, bool nan) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(val), std::forward(kind), std::forward(mask_and_clamp), std::forward(abs), std::forward(nan)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReduxOp ReduxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value val, ::mlir::NVVM::ReductionKind kind, ::mlir::Value mask_and_clamp, bool abs, bool nan) { return create(builder, builder.getLoc(), std::forward(res), std::forward(val), std::forward(kind), std::forward(mask_and_clamp), std::forward(abs), std::forward(nan)); } void ReduxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value val, ::mlir::NVVM::ReductionKind kind, ::mlir::Value mask_and_clamp, bool abs, bool nan) { odsState.addOperands(val); odsState.addOperands(mask_and_clamp); odsState.getOrAddProperties().kind = ::mlir::NVVM::ReductionKindAttr::get(odsBuilder.getContext(), kind); odsState.getOrAddProperties().abs = odsBuilder.getBoolAttr(abs); odsState.getOrAddProperties().nan = odsBuilder.getBoolAttr(nan); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ReduxOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ReduxOp ReduxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value val, ::mlir::NVVM::ReductionKind kind, ::mlir::Value mask_and_clamp, bool abs, bool nan) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(val), std::forward(kind), std::forward(mask_and_clamp), std::forward(abs), std::forward(nan)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReduxOp ReduxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value val, ::mlir::NVVM::ReductionKind kind, ::mlir::Value mask_and_clamp, bool abs, bool nan) { return create(builder, builder.getLoc(), std::forward(val), std::forward(kind), std::forward(mask_and_clamp), std::forward(abs), std::forward(nan)); } void ReduxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value val, ::mlir::NVVM::ReductionKind kind, ::mlir::Value mask_and_clamp, bool abs, bool nan) { odsState.addOperands(val); odsState.addOperands(mask_and_clamp); odsState.getOrAddProperties().kind = ::mlir::NVVM::ReductionKindAttr::get(odsBuilder.getContext(), kind); odsState.getOrAddProperties().abs = odsBuilder.getBoolAttr(abs); odsState.getOrAddProperties().nan = odsBuilder.getBoolAttr(nan); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReduxOp ReduxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value val, ::mlir::NVVM::ReductionKind kind, ::mlir::Value mask_and_clamp, bool abs, bool nan) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(val), std::forward(kind), std::forward(mask_and_clamp), std::forward(abs), std::forward(nan)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReduxOp ReduxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value val, ::mlir::NVVM::ReductionKind kind, ::mlir::Value mask_and_clamp, bool abs, bool nan) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(val), std::forward(kind), std::forward(mask_and_clamp), std::forward(abs), std::forward(nan)); } void ReduxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ReduxOp ReduxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReduxOp ReduxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ReduxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ReduxOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ReduxOp ReduxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReduxOp ReduxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ReduxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ReduxOp ReduxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReduxOp ReduxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ReduxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ReduxOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ReduxOp ReduxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReduxOp ReduxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ReduxOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.abs) properties.abs = odsBuilder.getBoolAttr(false); if (!properties.nan) properties.nan = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult ReduxOp::verifyInvariantsImpl() { auto tblgen_abs = getProperties().abs; (void)tblgen_abs; auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); auto tblgen_nan = getProperties().nan; (void)tblgen_nan; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps50(*this, tblgen_kind, "kind"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_abs, "abs"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_nan, "nan"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps37(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps37(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType()) && ((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSResults(0).begin()).getType())))) return emitOpError("failed to verify that all of {res, val} have same type"); return ::mlir::success(); } ::llvm::LogicalResult ReduxOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ReduxOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); if (operands.size() <= 0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[0].getType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ReduxOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::ReductionKindAttr kindAttr; ::mlir::OpAsmParser::UnresolvedOperand valRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valOperands(&valRawOperand, 1); ::llvm::SMLoc valOperandsLoc; (void)valOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand mask_and_clampRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> mask_and_clampOperands(&mask_and_clampRawOperand, 1); ::llvm::SMLoc mask_and_clampOperandsLoc; (void)mask_and_clampOperandsLoc; ::mlir::Type valRawType{}; ::llvm::ArrayRef<::mlir::Type> valTypes(&valRawType, 1); ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (parser.parseCustomAttributeWithFallback(kindAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (kindAttr) result.getOrAddProperties().kind = kindAttr; valOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(valRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); mask_and_clampOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(mask_and_clampRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); valRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); result.addTypes(resTypes); if (parser.resolveOperands(valOperands, valTypes, valOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(mask_and_clampOperands, odsBuildableType0, mask_and_clampOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ReduxOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getKindAttr()); _odsPrinter << ' '; _odsPrinter << getVal(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMaskAndClamp(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("kind"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getAbsAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("abs"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getNanAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("nan"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getVal().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ReduxOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ReduxOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::RsqrtOp definitions //===----------------------------------------------------------------------===// namespace detail { RsqrtOpGenericAdaptorBase::RsqrtOpGenericAdaptorBase(RsqrtOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::BoolAttr RsqrtOpGenericAdaptorBase::getFtzAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().ftz); return attr; } bool RsqrtOpGenericAdaptorBase::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } } // namespace detail RsqrtOpAdaptor::RsqrtOpAdaptor(RsqrtOp op) : RsqrtOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult RsqrtOpAdaptor::verify(::mlir::Location loc) { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; if (tblgen_ftz && !((::llvm::isa<::mlir::BoolAttr>(tblgen_ftz)))) return emitError(loc, "'nvvm.rsqrt' op attribute 'ftz' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult RsqrtOp::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.ftz; auto attr = dict.get("ftz"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ftz` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute RsqrtOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.ftz; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ftz", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code RsqrtOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.ftz.getAsOpaquePointer())); } std::optional RsqrtOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "ftz") return prop.ftz; return std::nullopt; } void RsqrtOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "ftz") { prop.ftz = ::llvm::dyn_cast_or_null>(value); return; } } void RsqrtOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.ftz) attrs.append("ftz", prop.ftz); } ::llvm::LogicalResult RsqrtOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFtzAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "ftz", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult RsqrtOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.ftz))) return ::mlir::failure(); return ::mlir::success(); } void RsqrtOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.ftz); } bool RsqrtOp::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } void RsqrtOp::setFtz(bool attrValue) { getProperties().ftz = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } odsState.addTypes(res); } RsqrtOp RsqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RsqrtOp RsqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(src), std::forward(ftz)); } void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(RsqrtOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } RsqrtOp RsqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RsqrtOp RsqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(src), std::forward(ftz)); } void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } RsqrtOp RsqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RsqrtOp RsqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(ftz)); } void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); odsState.addTypes(res); } RsqrtOp RsqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RsqrtOp RsqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(src), std::forward(ftz)); } void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(RsqrtOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } RsqrtOp RsqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RsqrtOp RsqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(src), std::forward(ftz)); } void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } RsqrtOp RsqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RsqrtOp RsqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(ftz)); } void RsqrtOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } RsqrtOp RsqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RsqrtOp RsqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(RsqrtOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } RsqrtOp RsqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RsqrtOp RsqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void RsqrtOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } RsqrtOp RsqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RsqrtOp RsqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(RsqrtOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } RsqrtOp RsqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RsqrtOp RsqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void RsqrtOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.ftz) properties.ftz = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult RsqrtOp::verifyInvariantsImpl() { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_ftz, "ftz"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps25(*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_NVVMOps25(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult RsqrtOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult RsqrtOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); if (operands.size() <= 0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[0].getType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult RsqrtOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } result.addTypes(srcTypes[0]); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void RsqrtOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFtzAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("ftz"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void RsqrtOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::RsqrtOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::RsqrtOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::SetMaxRegisterOp definitions //===----------------------------------------------------------------------===// namespace detail { SetMaxRegisterOpGenericAdaptorBase::SetMaxRegisterOpGenericAdaptorBase(SetMaxRegisterOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} uint32_t SetMaxRegisterOpGenericAdaptorBase::getRegCount() { auto attr = getRegCountAttr(); return attr.getValue().getZExtValue(); } ::mlir::NVVM::SetMaxRegisterAction SetMaxRegisterOpGenericAdaptorBase::getAction() { auto attr = getActionAttr(); return attr.getValue(); } } // namespace detail SetMaxRegisterOpAdaptor::SetMaxRegisterOpAdaptor(SetMaxRegisterOp op) : SetMaxRegisterOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult SetMaxRegisterOpAdaptor::verify(::mlir::Location loc) { auto tblgen_action = getProperties().action; (void)tblgen_action; if (!tblgen_action) return emitError(loc, "'nvvm.setmaxregister' op requires attribute 'action'"); auto tblgen_regCount = getProperties().regCount; (void)tblgen_regCount; if (!tblgen_regCount) return emitError(loc, "'nvvm.setmaxregister' op requires attribute 'regCount'"); if (tblgen_regCount && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_regCount))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_regCount).getType().isSignlessInteger(32))))) return emitError(loc, "'nvvm.setmaxregister' op attribute 'regCount' failed to satisfy constraint: 32-bit signless integer attribute"); if (tblgen_action && !((::llvm::isa<::mlir::NVVM::SetMaxRegisterActionAttr>(tblgen_action)))) return emitError(loc, "'nvvm.setmaxregister' op attribute 'action' failed to satisfy constraint: NVVM set max register action"); return ::mlir::success(); } ::llvm::LogicalResult SetMaxRegisterOp::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.action; auto attr = dict.get("action"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `action` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.regCount; auto attr = dict.get("regCount"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `regCount` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute SetMaxRegisterOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.action; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("action", propStorage)); } { const auto &propStorage = prop.regCount; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("regCount", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code SetMaxRegisterOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.action.getAsOpaquePointer()), llvm::hash_value(prop.regCount.getAsOpaquePointer())); } std::optional SetMaxRegisterOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "action") return prop.action; if (name == "regCount") return prop.regCount; return std::nullopt; } void SetMaxRegisterOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "action") { prop.action = ::llvm::dyn_cast_or_null>(value); return; } if (name == "regCount") { prop.regCount = ::llvm::dyn_cast_or_null>(value); return; } } void SetMaxRegisterOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.action) attrs.append("action", prop.action); if (prop.regCount) attrs.append("regCount", prop.regCount); } ::llvm::LogicalResult SetMaxRegisterOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getActionAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps51(attr, "action", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRegCountAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(attr, "regCount", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult SetMaxRegisterOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.action))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.regCount))) return ::mlir::failure(); return ::mlir::success(); } void SetMaxRegisterOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.action); writer.writeAttribute(prop.regCount); } uint32_t SetMaxRegisterOp::getRegCount() { auto attr = getRegCountAttr(); return attr.getValue().getZExtValue(); } ::mlir::NVVM::SetMaxRegisterAction SetMaxRegisterOp::getAction() { auto attr = getActionAttr(); return attr.getValue(); } void SetMaxRegisterOp::setRegCount(uint32_t attrValue) { getProperties().regCount = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); } void SetMaxRegisterOp::setAction(::mlir::NVVM::SetMaxRegisterAction attrValue) { getProperties().action = ::mlir::NVVM::SetMaxRegisterActionAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void SetMaxRegisterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::IntegerAttr regCount, ::mlir::NVVM::SetMaxRegisterActionAttr action) { odsState.getOrAddProperties().regCount = regCount; odsState.getOrAddProperties().action = action; } SetMaxRegisterOp SetMaxRegisterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::IntegerAttr regCount, ::mlir::NVVM::SetMaxRegisterActionAttr action) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(regCount), std::forward(action)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SetMaxRegisterOp SetMaxRegisterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::IntegerAttr regCount, ::mlir::NVVM::SetMaxRegisterActionAttr action) { return create(builder, builder.getLoc(), std::forward(regCount), std::forward(action)); } void SetMaxRegisterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr regCount, ::mlir::NVVM::SetMaxRegisterActionAttr action) { odsState.getOrAddProperties().regCount = regCount; odsState.getOrAddProperties().action = action; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } SetMaxRegisterOp SetMaxRegisterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr regCount, ::mlir::NVVM::SetMaxRegisterActionAttr action) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(regCount), std::forward(action)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SetMaxRegisterOp SetMaxRegisterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr regCount, ::mlir::NVVM::SetMaxRegisterActionAttr action) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(regCount), std::forward(action)); } void SetMaxRegisterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, uint32_t regCount, ::mlir::NVVM::SetMaxRegisterAction action) { odsState.getOrAddProperties().regCount = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), regCount); odsState.getOrAddProperties().action = ::mlir::NVVM::SetMaxRegisterActionAttr::get(odsBuilder.getContext(), action); } SetMaxRegisterOp SetMaxRegisterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, uint32_t regCount, ::mlir::NVVM::SetMaxRegisterAction action) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(regCount), std::forward(action)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SetMaxRegisterOp SetMaxRegisterOp::create(::mlir::ImplicitLocOpBuilder &builder, uint32_t regCount, ::mlir::NVVM::SetMaxRegisterAction action) { return create(builder, builder.getLoc(), std::forward(regCount), std::forward(action)); } void SetMaxRegisterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, uint32_t regCount, ::mlir::NVVM::SetMaxRegisterAction action) { odsState.getOrAddProperties().regCount = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), regCount); odsState.getOrAddProperties().action = ::mlir::NVVM::SetMaxRegisterActionAttr::get(odsBuilder.getContext(), action); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } SetMaxRegisterOp SetMaxRegisterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, uint32_t regCount, ::mlir::NVVM::SetMaxRegisterAction action) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(regCount), std::forward(action)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SetMaxRegisterOp SetMaxRegisterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, uint32_t regCount, ::mlir::NVVM::SetMaxRegisterAction action) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(regCount), std::forward(action)); } void SetMaxRegisterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } SetMaxRegisterOp SetMaxRegisterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SetMaxRegisterOp SetMaxRegisterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void SetMaxRegisterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } SetMaxRegisterOp SetMaxRegisterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SetMaxRegisterOp SetMaxRegisterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult SetMaxRegisterOp::verifyInvariantsImpl() { auto tblgen_action = getProperties().action; (void)tblgen_action; if (!tblgen_action) return emitOpError("requires attribute 'action'"); auto tblgen_regCount = getProperties().regCount; (void)tblgen_regCount; if (!tblgen_regCount) return emitOpError("requires attribute 'regCount'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(*this, tblgen_regCount, "regCount"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps51(*this, tblgen_action, "action"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult SetMaxRegisterOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult SetMaxRegisterOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::SetMaxRegisterActionAttr actionAttr; ::mlir::IntegerAttr regCountAttr; if (parser.parseCustomAttributeWithFallback(actionAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (actionAttr) result.getOrAddProperties().action = actionAttr; if (parser.parseCustomAttributeWithFallback(regCountAttr, parser.getBuilder().getIntegerType(32))) { return ::mlir::failure(); } if (regCountAttr) result.getOrAddProperties().regCount = regCountAttr; { 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 SetMaxRegisterOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getActionAttr()); _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getRegCountAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("action"); elidedAttrs.push_back("regCount"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::SetMaxRegisterOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::SetMaxRegisterOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ShflOp definitions //===----------------------------------------------------------------------===// namespace detail { ShflOpGenericAdaptorBase::ShflOpGenericAdaptorBase(ShflOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::ShflKind ShflOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::std::optional ShflOpGenericAdaptorBase::getReturnValueAndIsValid() { auto attr = getReturnValueAndIsValidAttr(); return attr ? ::std::optional(attr != nullptr) : (::std::nullopt); } } // namespace detail ShflOpAdaptor::ShflOpAdaptor(ShflOp op) : ShflOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ShflOpAdaptor::verify(::mlir::Location loc) { auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'nvvm.shfl.sync' op requires attribute 'kind'"); auto tblgen_return_value_and_is_valid = getProperties().return_value_and_is_valid; (void)tblgen_return_value_and_is_valid; if (tblgen_kind && !((::llvm::isa<::mlir::NVVM::ShflKindAttr>(tblgen_kind)))) return emitError(loc, "'nvvm.shfl.sync' op attribute 'kind' failed to satisfy constraint: NVVM shuffle kind"); if (tblgen_return_value_and_is_valid && !((::llvm::isa<::mlir::UnitAttr>(tblgen_return_value_and_is_valid)))) return emitError(loc, "'nvvm.shfl.sync' op attribute 'return_value_and_is_valid' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } ::llvm::LogicalResult ShflOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.return_value_and_is_valid; auto attr = dict.get("return_value_and_is_valid"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `return_value_and_is_valid` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ShflOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", propStorage)); } { const auto &propStorage = prop.return_value_and_is_valid; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("return_value_and_is_valid", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ShflOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.kind.getAsOpaquePointer()), llvm::hash_value(prop.return_value_and_is_valid.getAsOpaquePointer())); } std::optional ShflOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "kind") return prop.kind; if (name == "return_value_and_is_valid") return prop.return_value_and_is_valid; return std::nullopt; } void ShflOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } if (name == "return_value_and_is_valid") { prop.return_value_and_is_valid = ::llvm::dyn_cast_or_null>(value); return; } } void ShflOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.kind) attrs.append("kind", prop.kind); if (prop.return_value_and_is_valid) attrs.append("return_value_and_is_valid", prop.return_value_and_is_valid); } ::llvm::LogicalResult ShflOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps52(attr, "kind", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReturnValueAndIsValidAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "return_value_and_is_valid", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ShflOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.kind))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.return_value_and_is_valid))) return ::mlir::failure(); return ::mlir::success(); } void ShflOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.kind); writer.writeOptionalAttribute(prop.return_value_and_is_valid); } ::mlir::NVVM::ShflKind ShflOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::std::optional ShflOp::getReturnValueAndIsValid() { auto attr = getReturnValueAndIsValidAttr(); return attr ? ::std::optional(attr != nullptr) : (::std::nullopt); } void ShflOp::setKind(::mlir::NVVM::ShflKind attrValue) { getProperties().kind = ::mlir::NVVM::ShflKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ShflOp::setReturnValueAndIsValid(bool attrValue) { auto &odsProp = getProperties().return_value_and_is_valid; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void ShflOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKindAttr kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { odsState.addOperands(thread_mask); odsState.addOperands(val); odsState.addOperands(offset); odsState.addOperands(mask_and_clamp); odsState.getOrAddProperties().kind = kind; if (return_value_and_is_valid) { odsState.getOrAddProperties().return_value_and_is_valid = return_value_and_is_valid; } odsState.addTypes(res); } ShflOp ShflOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKindAttr kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(thread_mask), std::forward(val), std::forward(offset), std::forward(mask_and_clamp), std::forward(kind), std::forward(return_value_and_is_valid)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShflOp ShflOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKindAttr kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { return create(builder, builder.getLoc(), std::forward(res), std::forward(thread_mask), std::forward(val), std::forward(offset), std::forward(mask_and_clamp), std::forward(kind), std::forward(return_value_and_is_valid)); } void ShflOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKindAttr kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { odsState.addOperands(thread_mask); odsState.addOperands(val); odsState.addOperands(offset); odsState.addOperands(mask_and_clamp); odsState.getOrAddProperties().kind = kind; if (return_value_and_is_valid) { odsState.getOrAddProperties().return_value_and_is_valid = return_value_and_is_valid; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ShflOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ShflOp ShflOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKindAttr kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(thread_mask), std::forward(val), std::forward(offset), std::forward(mask_and_clamp), std::forward(kind), std::forward(return_value_and_is_valid)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShflOp ShflOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKindAttr kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { return create(builder, builder.getLoc(), std::forward(thread_mask), std::forward(val), std::forward(offset), std::forward(mask_and_clamp), std::forward(kind), std::forward(return_value_and_is_valid)); } void ShflOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKindAttr kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { odsState.addOperands(thread_mask); odsState.addOperands(val); odsState.addOperands(offset); odsState.addOperands(mask_and_clamp); odsState.getOrAddProperties().kind = kind; if (return_value_and_is_valid) { odsState.getOrAddProperties().return_value_and_is_valid = return_value_and_is_valid; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ShflOp ShflOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKindAttr kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(thread_mask), std::forward(val), std::forward(offset), std::forward(mask_and_clamp), std::forward(kind), std::forward(return_value_and_is_valid)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShflOp ShflOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKindAttr kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(thread_mask), std::forward(val), std::forward(offset), std::forward(mask_and_clamp), std::forward(kind), std::forward(return_value_and_is_valid)); } void ShflOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKind kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { odsState.addOperands(thread_mask); odsState.addOperands(val); odsState.addOperands(offset); odsState.addOperands(mask_and_clamp); odsState.getOrAddProperties().kind = ::mlir::NVVM::ShflKindAttr::get(odsBuilder.getContext(), kind); if (return_value_and_is_valid) { odsState.getOrAddProperties().return_value_and_is_valid = return_value_and_is_valid; } odsState.addTypes(res); } ShflOp ShflOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKind kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(thread_mask), std::forward(val), std::forward(offset), std::forward(mask_and_clamp), std::forward(kind), std::forward(return_value_and_is_valid)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShflOp ShflOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKind kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { return create(builder, builder.getLoc(), std::forward(res), std::forward(thread_mask), std::forward(val), std::forward(offset), std::forward(mask_and_clamp), std::forward(kind), std::forward(return_value_and_is_valid)); } void ShflOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKind kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { odsState.addOperands(thread_mask); odsState.addOperands(val); odsState.addOperands(offset); odsState.addOperands(mask_and_clamp); odsState.getOrAddProperties().kind = ::mlir::NVVM::ShflKindAttr::get(odsBuilder.getContext(), kind); if (return_value_and_is_valid) { odsState.getOrAddProperties().return_value_and_is_valid = return_value_and_is_valid; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ShflOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ShflOp ShflOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKind kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(thread_mask), std::forward(val), std::forward(offset), std::forward(mask_and_clamp), std::forward(kind), std::forward(return_value_and_is_valid)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShflOp ShflOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKind kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { return create(builder, builder.getLoc(), std::forward(thread_mask), std::forward(val), std::forward(offset), std::forward(mask_and_clamp), std::forward(kind), std::forward(return_value_and_is_valid)); } void ShflOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKind kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { odsState.addOperands(thread_mask); odsState.addOperands(val); odsState.addOperands(offset); odsState.addOperands(mask_and_clamp); odsState.getOrAddProperties().kind = ::mlir::NVVM::ShflKindAttr::get(odsBuilder.getContext(), kind); if (return_value_and_is_valid) { odsState.getOrAddProperties().return_value_and_is_valid = return_value_and_is_valid; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ShflOp ShflOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKind kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(thread_mask), std::forward(val), std::forward(offset), std::forward(mask_and_clamp), std::forward(kind), std::forward(return_value_and_is_valid)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShflOp ShflOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value thread_mask, ::mlir::Value val, ::mlir::Value offset, ::mlir::Value mask_and_clamp, ::mlir::NVVM::ShflKind kind, /*optional*/::mlir::UnitAttr return_value_and_is_valid) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(thread_mask), std::forward(val), std::forward(offset), std::forward(mask_and_clamp), std::forward(kind), std::forward(return_value_and_is_valid)); } void ShflOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 4u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ShflOp ShflOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShflOp ShflOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ShflOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 4u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ShflOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ShflOp ShflOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShflOp ShflOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ShflOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 4u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ShflOp ShflOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShflOp ShflOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ShflOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 4u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ShflOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ShflOp ShflOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShflOp ShflOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ShflOp::verifyInvariantsImpl() { auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); auto tblgen_return_value_and_is_valid = getProperties().return_value_and_is_valid; (void)tblgen_return_value_and_is_valid; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps52(*this, tblgen_kind, "kind"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_return_value_and_is_valid, "return_value_and_is_valid"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps37(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps38(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ShflOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ShflOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::ShflKindAttr kindAttr; ::mlir::OpAsmParser::UnresolvedOperand thread_maskRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> thread_maskOperands(&thread_maskRawOperand, 1); ::llvm::SMLoc thread_maskOperandsLoc; (void)thread_maskOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand valRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valOperands(&valRawOperand, 1); ::llvm::SMLoc valOperandsLoc; (void)valOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand offsetRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> offsetOperands(&offsetRawOperand, 1); ::llvm::SMLoc offsetOperandsLoc; (void)offsetOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand mask_and_clampRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> mask_and_clampOperands(&mask_and_clampRawOperand, 1); ::llvm::SMLoc mask_and_clampOperandsLoc; (void)mask_and_clampOperandsLoc; ::mlir::Type valRawType{}; ::llvm::ArrayRef<::mlir::Type> valTypes(&valRawType, 1); ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (parser.parseCustomAttributeWithFallback(kindAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (kindAttr) result.getOrAddProperties().kind = kindAttr; thread_maskOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(thread_maskRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); valOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(valRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); offsetOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(offsetRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); mask_and_clampOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(mask_and_clampRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); valRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); result.addTypes(resTypes); if (parser.resolveOperands(thread_maskOperands, odsBuildableType0, thread_maskOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(valOperands, valTypes, valOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(offsetOperands, odsBuildableType0, offsetOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(mask_and_clampOperands, odsBuildableType0, mask_and_clampOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ShflOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getKindAttr()); _odsPrinter << ' '; _odsPrinter << getThreadMask(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getVal(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getOffset(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMaskAndClamp(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("kind"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getVal().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } ::llvm::LogicalResult ShflOp::inferReturnTypes(::mlir::MLIRContext *context, std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { ShflOp::Adaptor adaptor(operands, attributes, properties, regions); return ShflOp::inferReturnTypes(context, location, adaptor, inferredReturnTypes); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ShflOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ShflOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::SinOp definitions //===----------------------------------------------------------------------===// namespace detail { SinOpGenericAdaptorBase::SinOpGenericAdaptorBase(SinOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::BoolAttr SinOpGenericAdaptorBase::getFtzAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().ftz); return attr; } bool SinOpGenericAdaptorBase::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } } // namespace detail SinOpAdaptor::SinOpAdaptor(SinOp op) : SinOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult SinOpAdaptor::verify(::mlir::Location loc) { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; if (tblgen_ftz && !((::llvm::isa<::mlir::BoolAttr>(tblgen_ftz)))) return emitError(loc, "'nvvm.sin' op attribute 'ftz' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult SinOp::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.ftz; auto attr = dict.get("ftz"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ftz` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute SinOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.ftz; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ftz", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code SinOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.ftz.getAsOpaquePointer())); } std::optional SinOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "ftz") return prop.ftz; return std::nullopt; } void SinOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "ftz") { prop.ftz = ::llvm::dyn_cast_or_null>(value); return; } } void SinOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.ftz) attrs.append("ftz", prop.ftz); } ::llvm::LogicalResult SinOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFtzAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "ftz", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult SinOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.ftz))) return ::mlir::failure(); return ::mlir::success(); } void SinOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.ftz); } bool SinOp::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } void SinOp::setFtz(bool attrValue) { getProperties().ftz = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void SinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } odsState.addTypes(res); } SinOp SinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SinOp SinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(src), std::forward(ftz)); } void SinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SinOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } SinOp SinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SinOp SinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(src), std::forward(ftz)); } void SinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SinOp SinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SinOp SinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(ftz)); } void SinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); odsState.addTypes(res); } SinOp SinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SinOp SinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(src), std::forward(ftz)); } void SinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SinOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } SinOp SinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SinOp SinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(src), std::forward(ftz)); } void SinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SinOp SinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SinOp SinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(ftz)); } void SinOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } SinOp SinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SinOp SinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void SinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SinOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } SinOp SinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SinOp SinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void SinOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } SinOp SinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SinOp SinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void SinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SinOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } SinOp SinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SinOp SinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void SinOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.ftz) properties.ftz = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult SinOp::verifyInvariantsImpl() { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_ftz, "ftz"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*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_NVVMOps13(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult SinOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult SinOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); if (operands.size() <= 0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[0].getType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult SinOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) 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::FloatType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } result.addTypes(srcTypes[0]); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void SinOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFtzAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("ftz"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::FloatType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void SinOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::SinOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::SinOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::SmDimOp definitions //===----------------------------------------------------------------------===// namespace detail { SmDimOpGenericAdaptorBase::SmDimOpGenericAdaptorBase(SmDimOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> SmDimOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail SmDimOpAdaptor::SmDimOpAdaptor(SmDimOp op) : SmDimOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult SmDimOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.nsmid' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult SmDimOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute SmDimOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code SmDimOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional SmDimOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void SmDimOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void SmDimOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult SmDimOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult SmDimOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void SmDimOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> SmDimOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void SmDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } SmDimOp SmDimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SmDimOp SmDimOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void SmDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } SmDimOp SmDimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SmDimOp SmDimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void SmDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SmDimOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } SmDimOp SmDimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SmDimOp SmDimOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void SmDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SmDimOp SmDimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SmDimOp SmDimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void SmDimOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } SmDimOp SmDimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SmDimOp SmDimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void SmDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SmDimOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } SmDimOp SmDimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SmDimOp SmDimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void SmDimOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } SmDimOp SmDimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SmDimOp SmDimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void SmDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SmDimOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } SmDimOp SmDimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SmDimOp SmDimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult SmDimOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult SmDimOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult SmDimOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult SmDimOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void SmDimOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void SmDimOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void SmDimOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult SmDimOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::SmDimOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::SmDimOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::SmIdOp definitions //===----------------------------------------------------------------------===// namespace detail { SmIdOpGenericAdaptorBase::SmIdOpGenericAdaptorBase(SmIdOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> SmIdOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail SmIdOpAdaptor::SmIdOpAdaptor(SmIdOp op) : SmIdOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult SmIdOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.smid' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult SmIdOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute SmIdOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code SmIdOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional SmIdOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void SmIdOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void SmIdOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult SmIdOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult SmIdOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void SmIdOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> SmIdOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void SmIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } SmIdOp SmIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SmIdOp SmIdOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void SmIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } SmIdOp SmIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SmIdOp SmIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void SmIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SmIdOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } SmIdOp SmIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SmIdOp SmIdOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void SmIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SmIdOp SmIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SmIdOp SmIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void SmIdOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } SmIdOp SmIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SmIdOp SmIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void SmIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SmIdOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } SmIdOp SmIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SmIdOp SmIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void SmIdOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } SmIdOp SmIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SmIdOp SmIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void SmIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SmIdOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } SmIdOp SmIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SmIdOp SmIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult SmIdOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult SmIdOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult SmIdOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult SmIdOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void SmIdOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void SmIdOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void SmIdOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult SmIdOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::SmIdOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::SmIdOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::SqrtApproxOp definitions //===----------------------------------------------------------------------===// namespace detail { SqrtApproxOpGenericAdaptorBase::SqrtApproxOpGenericAdaptorBase(SqrtApproxOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::BoolAttr SqrtApproxOpGenericAdaptorBase::getFtzAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().ftz); return attr; } bool SqrtApproxOpGenericAdaptorBase::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } } // namespace detail SqrtApproxOpAdaptor::SqrtApproxOpAdaptor(SqrtApproxOp op) : SqrtApproxOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult SqrtApproxOpAdaptor::verify(::mlir::Location loc) { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; if (tblgen_ftz && !((::llvm::isa<::mlir::BoolAttr>(tblgen_ftz)))) return emitError(loc, "'nvvm.sqrt.approx' op attribute 'ftz' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult SqrtApproxOp::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.ftz; auto attr = dict.get("ftz"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ftz` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute SqrtApproxOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.ftz; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ftz", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code SqrtApproxOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.ftz.getAsOpaquePointer())); } std::optional SqrtApproxOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "ftz") return prop.ftz; return std::nullopt; } void SqrtApproxOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "ftz") { prop.ftz = ::llvm::dyn_cast_or_null>(value); return; } } void SqrtApproxOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.ftz) attrs.append("ftz", prop.ftz); } ::llvm::LogicalResult SqrtApproxOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFtzAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "ftz", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult SqrtApproxOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.ftz))) return ::mlir::failure(); return ::mlir::success(); } void SqrtApproxOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.ftz); } bool SqrtApproxOp::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } void SqrtApproxOp::setFtz(bool attrValue) { getProperties().ftz = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void SqrtApproxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } odsState.addTypes(res); } SqrtApproxOp SqrtApproxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtApproxOp SqrtApproxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(src), std::forward(ftz)); } void SqrtApproxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SqrtApproxOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } SqrtApproxOp SqrtApproxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtApproxOp SqrtApproxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(src), std::forward(ftz)); } void SqrtApproxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { odsState.addOperands(src); if (ftz) { odsState.getOrAddProperties().ftz = ftz; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SqrtApproxOp SqrtApproxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtApproxOp SqrtApproxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(ftz)); } void SqrtApproxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); odsState.addTypes(res); } SqrtApproxOp SqrtApproxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtApproxOp SqrtApproxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(src), std::forward(ftz)); } void SqrtApproxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SqrtApproxOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } SqrtApproxOp SqrtApproxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtApproxOp SqrtApproxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(src), std::forward(ftz)); } void SqrtApproxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SqrtApproxOp SqrtApproxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtApproxOp SqrtApproxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, bool ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(ftz)); } void SqrtApproxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } SqrtApproxOp SqrtApproxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtApproxOp SqrtApproxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void SqrtApproxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SqrtApproxOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } SqrtApproxOp SqrtApproxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtApproxOp SqrtApproxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void SqrtApproxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } SqrtApproxOp SqrtApproxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtApproxOp SqrtApproxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void SqrtApproxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SqrtApproxOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } SqrtApproxOp SqrtApproxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtApproxOp SqrtApproxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void SqrtApproxOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.ftz) properties.ftz = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult SqrtApproxOp::verifyInvariantsImpl() { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_ftz, "ftz"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps13(*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_NVVMOps13(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult SqrtApproxOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult SqrtApproxOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); if (operands.size() <= 0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[0].getType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult SqrtApproxOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) 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::FloatType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } result.addTypes(srcTypes[0]); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void SqrtApproxOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFtzAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("ftz"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::FloatType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void SqrtApproxOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::SqrtApproxOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::SqrtApproxOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::SqrtOp definitions //===----------------------------------------------------------------------===// namespace detail { SqrtOpGenericAdaptorBase::SqrtOpGenericAdaptorBase(SqrtOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::FPRoundingMode SqrtOpGenericAdaptorBase::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::BoolAttr SqrtOpGenericAdaptorBase::getFtzAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().ftz); return attr; } bool SqrtOpGenericAdaptorBase::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } } // namespace detail SqrtOpAdaptor::SqrtOpAdaptor(SqrtOp op) : SqrtOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult SqrtOpAdaptor::verify(::mlir::Location loc) { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; if (!tblgen_rnd) return emitError(loc, "'nvvm.sqrt' op requires attribute 'rnd'"); if (tblgen_rnd && !(((::llvm::isa<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd))) && (((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::NONE)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RM)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RN)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RP)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RZ))))) return emitError(loc, "'nvvm.sqrt' op attribute 'rnd' failed to satisfy constraint: NVVM FPRoundingMode kind whose value is one of {none, rm, rn, rp, rz}"); if (tblgen_ftz && !((::llvm::isa<::mlir::BoolAttr>(tblgen_ftz)))) return emitError(loc, "'nvvm.sqrt' op attribute 'ftz' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult SqrtOp::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.ftz; auto attr = dict.get("ftz"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ftz` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.rnd; auto attr = dict.get("rnd"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `rnd` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute SqrtOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.ftz; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ftz", propStorage)); } { const auto &propStorage = prop.rnd; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("rnd", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code SqrtOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.ftz.getAsOpaquePointer()), llvm::hash_value(prop.rnd.getAsOpaquePointer())); } std::optional SqrtOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "ftz") return prop.ftz; if (name == "rnd") return prop.rnd; return std::nullopt; } void SqrtOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "ftz") { prop.ftz = ::llvm::dyn_cast_or_null>(value); return; } if (name == "rnd") { prop.rnd = ::llvm::dyn_cast_or_null>(value); return; } } void SqrtOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.ftz) attrs.append("ftz", prop.ftz); if (prop.rnd) attrs.append("rnd", prop.rnd); } ::llvm::LogicalResult SqrtOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFtzAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "ftz", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRndAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps1(attr, "rnd", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult SqrtOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.ftz))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.rnd))) return ::mlir::failure(); return ::mlir::success(); } void SqrtOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.ftz); writer.writeAttribute(prop.rnd); } ::mlir::NVVM::FPRoundingMode SqrtOp::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } bool SqrtOp::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } void SqrtOp::setRnd(::mlir::NVVM::FPRoundingMode attrValue) { getProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void SqrtOp::setFtz(bool attrValue) { getProperties().ftz = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void SqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz) { odsState.addOperands(src); odsState.getOrAddProperties().rnd = rnd; if (ftz) { odsState.getOrAddProperties().ftz = ftz; } odsState.addTypes(res); } SqrtOp SqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(src), std::forward(rnd), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtOp SqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(src), std::forward(rnd), std::forward(ftz)); } void SqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz) { odsState.addOperands(src); odsState.getOrAddProperties().rnd = rnd; if (ftz) { odsState.getOrAddProperties().ftz = ftz; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SqrtOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } SqrtOp SqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(rnd), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtOp SqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(src), std::forward(rnd), std::forward(ftz)); } void SqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz) { odsState.addOperands(src); odsState.getOrAddProperties().rnd = rnd; if (ftz) { odsState.getOrAddProperties().ftz = ftz; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SqrtOp SqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(rnd), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtOp SqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(rnd), std::forward(ftz)); } void SqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); odsState.addTypes(res); } SqrtOp SqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(src), std::forward(rnd), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtOp SqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, bool ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(src), std::forward(rnd), std::forward(ftz)); } void SqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SqrtOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } SqrtOp SqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(rnd), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtOp SqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, bool ftz) { return create(builder, builder.getLoc(), std::forward(src), std::forward(rnd), std::forward(ftz)); } void SqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, bool ftz) { odsState.addOperands(src); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SqrtOp SqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(rnd), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtOp SqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::NVVM::FPRoundingMode rnd, bool ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(rnd), std::forward(ftz)); } void SqrtOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } SqrtOp SqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtOp SqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void SqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SqrtOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } SqrtOp SqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtOp SqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void SqrtOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } SqrtOp SqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtOp SqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void SqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SqrtOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } SqrtOp SqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SqrtOp SqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void SqrtOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.ftz) properties.ftz = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult SqrtOp::verifyInvariantsImpl() { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; if (!tblgen_rnd) return emitOpError("requires attribute 'rnd'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps1(*this, tblgen_rnd, "rnd"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_ftz, "ftz"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps25(*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_NVVMOps25(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult SqrtOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult SqrtOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); if (operands.size() <= 0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[0].getType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult SqrtOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } result.addTypes(srcTypes[0]); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void SqrtOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFtzAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("ftz"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void SqrtOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::SqrtOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::SqrtOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::StMatrixOp definitions //===----------------------------------------------------------------------===// namespace detail { StMatrixOpGenericAdaptorBase::StMatrixOpGenericAdaptorBase(StMatrixOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair StMatrixOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::NVVM::MMALayout StMatrixOpGenericAdaptorBase::getLayout() { auto attr = getLayoutAttr(); return attr.getValue(); } ::mlir::NVVM::LdStMatrixShapeAttr StMatrixOpGenericAdaptorBase::getShape() { auto attr = getShapeAttr(); return ::llvm::cast<::mlir::NVVM::LdStMatrixShapeAttr>(attr); } ::mlir::NVVM::LdStMatrixEltType StMatrixOpGenericAdaptorBase::getEltType() { auto attr = getEltTypeAttr(); return attr.getValue(); } } // namespace detail StMatrixOpAdaptor::StMatrixOpAdaptor(StMatrixOp op) : StMatrixOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult StMatrixOpAdaptor::verify(::mlir::Location loc) { auto tblgen_eltType = getProperties().eltType; (void)tblgen_eltType; if (!tblgen_eltType) return emitError(loc, "'nvvm.stmatrix' op requires attribute 'eltType'"); auto tblgen_layout = getProperties().layout; (void)tblgen_layout; if (!tblgen_layout) return emitError(loc, "'nvvm.stmatrix' op requires attribute 'layout'"); auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitError(loc, "'nvvm.stmatrix' op requires attribute 'shape'"); if (tblgen_layout && !((::llvm::isa<::mlir::NVVM::MMALayoutAttr>(tblgen_layout)))) return emitError(loc, "'nvvm.stmatrix' op attribute 'layout' failed to satisfy constraint: NVVM MMA layout"); if (tblgen_shape && !((::llvm::isa<::mlir::NVVM::LdStMatrixShapeAttr>(tblgen_shape)))) return emitError(loc, "'nvvm.stmatrix' op attribute 'shape' failed to satisfy constraint: Matrix shape for ldmatrix and stmatrix"); if (tblgen_eltType && !((::llvm::isa<::mlir::NVVM::LdStMatrixEltTypeAttr>(tblgen_eltType)))) return emitError(loc, "'nvvm.stmatrix' op attribute 'eltType' failed to satisfy constraint: Element type for ldmatrix and stmatrix"); return ::mlir::success(); } std::pair StMatrixOp::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 StMatrixOp::getSourcesMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult StMatrixOp::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.eltType; auto attr = dict.get("eltType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `eltType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.layout; auto attr = dict.get("layout"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `layout` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.shape; auto attr = dict.get("shape"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `shape` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute StMatrixOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.eltType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("eltType", propStorage)); } { const auto &propStorage = prop.layout; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("layout", propStorage)); } { const auto &propStorage = prop.shape; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("shape", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code StMatrixOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.eltType.getAsOpaquePointer()), llvm::hash_value(prop.layout.getAsOpaquePointer()), llvm::hash_value(prop.shape.getAsOpaquePointer())); } std::optional StMatrixOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "eltType") return prop.eltType; if (name == "layout") return prop.layout; if (name == "shape") return prop.shape; return std::nullopt; } void StMatrixOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "eltType") { prop.eltType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "layout") { prop.layout = ::llvm::dyn_cast_or_null>(value); return; } if (name == "shape") { prop.shape = ::llvm::dyn_cast_or_null>(value); return; } } void StMatrixOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.eltType) attrs.append("eltType", prop.eltType); if (prop.layout) attrs.append("layout", prop.layout); if (prop.shape) attrs.append("shape", prop.shape); } ::llvm::LogicalResult StMatrixOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getEltTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps36(attr, "eltType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getLayoutAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(attr, "layout", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getShapeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps35(attr, "shape", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult StMatrixOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.eltType))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.layout))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.shape))) return ::mlir::failure(); return ::mlir::success(); } void StMatrixOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.eltType); writer.writeAttribute(prop.layout); writer.writeAttribute(prop.shape); } ::mlir::NVVM::MMALayout StMatrixOp::getLayout() { auto attr = getLayoutAttr(); return attr.getValue(); } ::mlir::NVVM::LdStMatrixShapeAttr StMatrixOp::getShape() { auto attr = getShapeAttr(); return ::llvm::cast<::mlir::NVVM::LdStMatrixShapeAttr>(attr); } ::mlir::NVVM::LdStMatrixEltType StMatrixOp::getEltType() { auto attr = getEltTypeAttr(); return attr.getValue(); } void StMatrixOp::setLayout(::mlir::NVVM::MMALayout attrValue) { getProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void StMatrixOp::setEltType(::mlir::NVVM::LdStMatrixEltType attrValue) { getProperties().eltType = ::mlir::NVVM::LdStMatrixEltTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void StMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value ptr, ::mlir::ValueRange sources, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { odsState.addOperands(ptr); odsState.addOperands(sources); odsState.getOrAddProperties().layout = layout; odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().eltType = eltType; } StMatrixOp StMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value ptr, ::mlir::ValueRange sources, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(ptr), std::forward(sources), std::forward(layout), std::forward(shape), std::forward(eltType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } StMatrixOp StMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value ptr, ::mlir::ValueRange sources, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { return create(builder, builder.getLoc(), std::forward(ptr), std::forward(sources), std::forward(layout), std::forward(shape), std::forward(eltType)); } void StMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::ValueRange sources, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { odsState.addOperands(ptr); odsState.addOperands(sources); odsState.getOrAddProperties().layout = layout; odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().eltType = eltType; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } StMatrixOp StMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::ValueRange sources, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ptr), std::forward(sources), std::forward(layout), std::forward(shape), std::forward(eltType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } StMatrixOp StMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::ValueRange sources, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltTypeAttr eltType) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ptr), std::forward(sources), std::forward(layout), std::forward(shape), std::forward(eltType)); } void StMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value ptr, ::mlir::ValueRange sources, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltType eltType) { odsState.addOperands(ptr); odsState.addOperands(sources); odsState.getOrAddProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layout); odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().eltType = ::mlir::NVVM::LdStMatrixEltTypeAttr::get(odsBuilder.getContext(), eltType); } StMatrixOp StMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value ptr, ::mlir::ValueRange sources, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltType eltType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(ptr), std::forward(sources), std::forward(layout), std::forward(shape), std::forward(eltType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } StMatrixOp StMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value ptr, ::mlir::ValueRange sources, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltType eltType) { return create(builder, builder.getLoc(), std::forward(ptr), std::forward(sources), std::forward(layout), std::forward(shape), std::forward(eltType)); } void StMatrixOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::ValueRange sources, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltType eltType) { odsState.addOperands(ptr); odsState.addOperands(sources); odsState.getOrAddProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layout); odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().eltType = ::mlir::NVVM::LdStMatrixEltTypeAttr::get(odsBuilder.getContext(), eltType); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } StMatrixOp StMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::ValueRange sources, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltType eltType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ptr), std::forward(sources), std::forward(layout), std::forward(shape), std::forward(eltType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } StMatrixOp StMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::ValueRange sources, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::LdStMatrixShapeAttr shape, ::mlir::NVVM::LdStMatrixEltType eltType) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ptr), std::forward(sources), std::forward(layout), std::forward(shape), std::forward(eltType)); } void StMatrixOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } StMatrixOp StMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } StMatrixOp StMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void StMatrixOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } StMatrixOp StMatrixOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } StMatrixOp StMatrixOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult StMatrixOp::verifyInvariantsImpl() { auto tblgen_eltType = getProperties().eltType; (void)tblgen_eltType; if (!tblgen_eltType) return emitOpError("requires attribute 'eltType'"); auto tblgen_layout = getProperties().layout; (void)tblgen_layout; if (!tblgen_layout) return emitOpError("requires attribute 'layout'"); auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitOpError("requires attribute 'shape'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(*this, tblgen_layout, "layout"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps35(*this, tblgen_shape, "shape"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps36(*this, tblgen_eltType, "eltType"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps21(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult StMatrixOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult StMatrixOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand ptrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> ptrOperands(&ptrRawOperand, 1); ::llvm::SMLoc ptrOperandsLoc; (void)ptrOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> sourcesOperands; ::llvm::SMLoc sourcesOperandsLoc; (void)sourcesOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; ptrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(ptrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); sourcesOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(sourcesOperands)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.resolveOperands(::llvm::concat(ptrOperands, sourcesOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void StMatrixOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getPtr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSources(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::StMatrixOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::StMatrixOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::SubFOp definitions //===----------------------------------------------------------------------===// namespace detail { SubFOpGenericAdaptorBase::SubFOpGenericAdaptorBase(SubFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::FPRoundingModeAttr SubFOpGenericAdaptorBase::getRndAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::FPRoundingModeAttr>(getProperties().rnd); return attr; } ::mlir::NVVM::FPRoundingMode SubFOpGenericAdaptorBase::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::NVVM::SaturationModeAttr SubFOpGenericAdaptorBase::getSatAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::SaturationModeAttr>(getProperties().sat); return attr; } ::mlir::NVVM::SaturationMode SubFOpGenericAdaptorBase::getSat() { auto attr = getSatAttr(); return attr.getValue(); } ::mlir::BoolAttr SubFOpGenericAdaptorBase::getFtzAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().ftz); return attr; } bool SubFOpGenericAdaptorBase::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } } // namespace detail SubFOpAdaptor::SubFOpAdaptor(SubFOp op) : SubFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult SubFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (tblgen_rnd && !(((::llvm::isa<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd))) && (((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::NONE)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RM)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RN)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RP)) || ((::llvm::cast<::mlir::NVVM::FPRoundingModeAttr>(tblgen_rnd).getValue() == ::mlir::NVVM::FPRoundingMode::RZ))))) return emitError(loc, "'nvvm.subf' op attribute 'rnd' failed to satisfy constraint: NVVM FPRoundingMode kind whose value is one of {none, rm, rn, rp, rz}"); if (tblgen_sat && !(((::llvm::isa<::mlir::NVVM::SaturationModeAttr>(tblgen_sat))) && (((::llvm::cast<::mlir::NVVM::SaturationModeAttr>(tblgen_sat).getValue() == ::mlir::NVVM::SaturationMode::NONE)) || ((::llvm::cast<::mlir::NVVM::SaturationModeAttr>(tblgen_sat).getValue() == ::mlir::NVVM::SaturationMode::SAT))))) return emitError(loc, "'nvvm.subf' op attribute 'sat' failed to satisfy constraint: Describes the saturation mode whose value is one of {none, sat}"); if (tblgen_ftz && !((::llvm::isa<::mlir::BoolAttr>(tblgen_ftz)))) return emitError(loc, "'nvvm.subf' op attribute 'ftz' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } ::llvm::LogicalResult SubFOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.ftz; auto attr = dict.get("ftz"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ftz` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.rnd; auto attr = dict.get("rnd"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `rnd` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sat; auto attr = dict.get("sat"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sat` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute SubFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.ftz; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ftz", propStorage)); } { const auto &propStorage = prop.rnd; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("rnd", propStorage)); } { const auto &propStorage = prop.sat; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sat", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code SubFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.ftz.getAsOpaquePointer()), llvm::hash_value(prop.rnd.getAsOpaquePointer()), llvm::hash_value(prop.sat.getAsOpaquePointer())); } std::optional SubFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "ftz") return prop.ftz; if (name == "rnd") return prop.rnd; if (name == "sat") return prop.sat; return std::nullopt; } void SubFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "ftz") { prop.ftz = ::llvm::dyn_cast_or_null>(value); return; } if (name == "rnd") { prop.rnd = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sat") { prop.sat = ::llvm::dyn_cast_or_null>(value); return; } } void SubFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.ftz) attrs.append("ftz", prop.ftz); if (prop.rnd) attrs.append("rnd", prop.rnd); if (prop.sat) attrs.append("sat", prop.sat); } ::llvm::LogicalResult SubFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFtzAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(attr, "ftz", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRndAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps1(attr, "rnd", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSatAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps2(attr, "sat", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult SubFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.ftz))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.rnd))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.sat))) return ::mlir::failure(); return ::mlir::success(); } void SubFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.ftz); writer.writeOptionalAttribute(prop.rnd); writer.writeOptionalAttribute(prop.sat); } ::mlir::NVVM::FPRoundingMode SubFOp::getRnd() { auto attr = getRndAttr(); return attr.getValue(); } ::mlir::NVVM::SaturationMode SubFOp::getSat() { auto attr = getSatAttr(); return attr.getValue(); } bool SubFOp::getFtz() { auto attr = getFtzAttr(); return attr.getValue(); } void SubFOp::setRnd(::mlir::NVVM::FPRoundingMode attrValue) { getProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void SubFOp::setSat(::mlir::NVVM::SaturationMode attrValue) { getProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void SubFOp::setFtz(bool attrValue) { getProperties().ftz = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (ftz) { odsState.getOrAddProperties().ftz = ftz; } odsState.addTypes(res); } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (ftz) { odsState.getOrAddProperties().ftz = ftz; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SubFOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (rnd) { odsState.getOrAddProperties().rnd = rnd; } if (sat) { odsState.getOrAddProperties().sat = sat; } if (ftz) { odsState.getOrAddProperties().ftz = ftz; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingModeAttr rnd, ::mlir::NVVM::SaturationModeAttr sat, ::mlir::BoolAttr ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); odsState.addTypes(res); } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { return create(builder, builder.getLoc(), std::forward(res), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SubFOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), rnd); odsState.getOrAddProperties().sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), sat); odsState.getOrAddProperties().ftz = odsBuilder.getBoolAttr(ftz); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::NVVM::FPRoundingMode rnd, ::mlir::NVVM::SaturationMode sat, bool ftz) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(rnd), std::forward(sat), std::forward(ftz)); } void SubFOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SubFOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void SubFOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SubFOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void SubFOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.rnd) properties.rnd = ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), FPRoundingMode::NONE); if (!properties.sat) properties.sat = ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE); if (!properties.ftz) properties.ftz = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult SubFOp::verifyInvariantsImpl() { auto tblgen_ftz = getProperties().ftz; (void)tblgen_ftz; auto tblgen_rnd = getProperties().rnd; (void)tblgen_rnd; auto tblgen_sat = getProperties().sat; (void)tblgen_sat; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps1(*this, tblgen_rnd, "rnd"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps2(*this, tblgen_sat, "sat"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps3(*this, tblgen_ftz, "ftz"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps1(*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_NVVMOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult SubFOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult SubFOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); if (operands.size() <= 0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[0].getType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult SubFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); if (parser.resolveOperands(lhsOperands, resTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void SubFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getRndAttr(); if(attr && (attr == ::mlir::NVVM::FPRoundingModeAttr::get(odsBuilder.getContext(), FPRoundingMode::NONE))) elidedAttrs.push_back("rnd"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getSatAttr(); if(attr && (attr == ::mlir::NVVM::SaturationModeAttr::get(odsBuilder.getContext(), SaturationMode::NONE))) elidedAttrs.push_back("sat"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFtzAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("ftz"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void SubFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::SubFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::SubFOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::SyncWarpOp definitions //===----------------------------------------------------------------------===// namespace detail { SyncWarpOpGenericAdaptorBase::SyncWarpOpGenericAdaptorBase(SyncWarpOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail SyncWarpOpAdaptor::SyncWarpOpAdaptor(SyncWarpOp op) : SyncWarpOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult SyncWarpOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult SyncWarpOp::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 SyncWarpOp::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 SyncWarpOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional SyncWarpOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void SyncWarpOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void SyncWarpOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult SyncWarpOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void SyncWarpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value mask) { odsState.addOperands(mask); } SyncWarpOp SyncWarpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value mask) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(mask)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SyncWarpOp SyncWarpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value mask) { return create(builder, builder.getLoc(), std::forward(mask)); } void SyncWarpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value mask) { odsState.addOperands(mask); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } SyncWarpOp SyncWarpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value mask) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(mask)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SyncWarpOp SyncWarpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value mask) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(mask)); } void SyncWarpOp::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); } SyncWarpOp SyncWarpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SyncWarpOp SyncWarpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void SyncWarpOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } SyncWarpOp SyncWarpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SyncWarpOp SyncWarpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult SyncWarpOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult SyncWarpOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult SyncWarpOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand maskRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> maskOperands(&maskRawOperand, 1); ::llvm::SMLoc maskOperandsLoc; (void)maskOperandsLoc; ::mlir::Type maskRawType{}; ::llvm::ArrayRef<::mlir::Type> maskTypes(&maskRawType, 1); maskOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(maskRawOperand)) 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(); maskRawType = type; } if (parser.resolveOperands(maskOperands, maskTypes, maskOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void SyncWarpOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getMask(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getMask().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::SyncWarpOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05AllocOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05AllocOpGenericAdaptorBase::Tcgen05AllocOpGenericAdaptorBase(Tcgen05AllocOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::CTAGroupKindAttr Tcgen05AllocOpGenericAdaptorBase::getGroupAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::CTAGroupKindAttr>(getProperties().group); return attr; } ::mlir::NVVM::CTAGroupKind Tcgen05AllocOpGenericAdaptorBase::getGroup() { auto attr = getGroupAttr(); return attr.getValue(); } } // namespace detail Tcgen05AllocOpAdaptor::Tcgen05AllocOpAdaptor(Tcgen05AllocOp op) : Tcgen05AllocOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05AllocOpAdaptor::verify(::mlir::Location loc) { auto tblgen_group = getProperties().group; (void)tblgen_group; if (tblgen_group && !((::llvm::isa<::mlir::NVVM::CTAGroupKindAttr>(tblgen_group)))) return emitError(loc, "'nvvm.tcgen05.alloc' op attribute 'group' failed to satisfy constraint: NVVM CTA group kind"); return ::mlir::success(); } ::llvm::LogicalResult Tcgen05AllocOp::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.group; auto attr = dict.get("group"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `group` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Tcgen05AllocOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.group; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("group", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Tcgen05AllocOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.group.getAsOpaquePointer())); } std::optional Tcgen05AllocOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "group") return prop.group; return std::nullopt; } void Tcgen05AllocOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "group") { prop.group = ::llvm::dyn_cast_or_null>(value); return; } } void Tcgen05AllocOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.group) attrs.append("group", prop.group); } ::llvm::LogicalResult Tcgen05AllocOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getGroupAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(attr, "group", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05AllocOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.group))) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05AllocOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.group); } ::mlir::NVVM::CTAGroupKind Tcgen05AllocOp::getGroup() { auto attr = getGroupAttr(); return attr.getValue(); } void Tcgen05AllocOp::setGroup(::mlir::NVVM::CTAGroupKind attrValue) { getProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05AllocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKindAttr group) { odsState.addOperands(addr); odsState.addOperands(nCols); if (group) { odsState.getOrAddProperties().group = group; } } Tcgen05AllocOp Tcgen05AllocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKindAttr group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(nCols), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05AllocOp Tcgen05AllocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKindAttr group) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(nCols), std::forward(group)); } void Tcgen05AllocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKindAttr group) { odsState.addOperands(addr); odsState.addOperands(nCols); if (group) { odsState.getOrAddProperties().group = group; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05AllocOp Tcgen05AllocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKindAttr group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(nCols), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05AllocOp Tcgen05AllocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKindAttr group) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(nCols), std::forward(group)); } void Tcgen05AllocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKind group) { odsState.addOperands(addr); odsState.addOperands(nCols); odsState.getOrAddProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), group); } Tcgen05AllocOp Tcgen05AllocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKind group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(nCols), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05AllocOp Tcgen05AllocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKind group) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(nCols), std::forward(group)); } void Tcgen05AllocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKind group) { odsState.addOperands(addr); odsState.addOperands(nCols); odsState.getOrAddProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), group); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05AllocOp Tcgen05AllocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKind group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(nCols), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05AllocOp Tcgen05AllocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKind group) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(nCols), std::forward(group)); } void Tcgen05AllocOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05AllocOp Tcgen05AllocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05AllocOp Tcgen05AllocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05AllocOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05AllocOp Tcgen05AllocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05AllocOp Tcgen05AllocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Tcgen05AllocOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.group) properties.group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), CTAGroupKind::CTA_1); } ::llvm::LogicalResult Tcgen05AllocOp::verifyInvariantsImpl() { auto tblgen_group = getProperties().group; (void)tblgen_group; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(*this, tblgen_group, "group"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps39(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05AllocOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult Tcgen05AllocOp::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 nColsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> nColsOperands(&nColsRawOperand, 1); ::llvm::SMLoc nColsOperandsLoc; (void)nColsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); nColsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(nColsRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.resolveOperands(::llvm::concat(addrOperands, nColsOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05AllocOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getNCols(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getGroupAttr(); if(attr && (attr == ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), CTAGroupKind::CTA_1))) elidedAttrs.push_back("group"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05AllocOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05AllocOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05CommitOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05CommitOpGenericAdaptorBase::Tcgen05CommitOpGenericAdaptorBase(Tcgen05CommitOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair Tcgen05CommitOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::NVVM::CTAGroupKindAttr Tcgen05CommitOpGenericAdaptorBase::getGroupAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::CTAGroupKindAttr>(getProperties().group); return attr; } ::mlir::NVVM::CTAGroupKind Tcgen05CommitOpGenericAdaptorBase::getGroup() { auto attr = getGroupAttr(); return attr.getValue(); } } // namespace detail Tcgen05CommitOpAdaptor::Tcgen05CommitOpAdaptor(Tcgen05CommitOp op) : Tcgen05CommitOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05CommitOpAdaptor::verify(::mlir::Location loc) { auto tblgen_group = getProperties().group; (void)tblgen_group; if (tblgen_group && !((::llvm::isa<::mlir::NVVM::CTAGroupKindAttr>(tblgen_group)))) return emitError(loc, "'nvvm.tcgen05.commit' op attribute 'group' failed to satisfy constraint: NVVM CTA group kind"); return ::mlir::success(); } std::pair Tcgen05CommitOp::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 Tcgen05CommitOp::getMulticastMaskMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult Tcgen05CommitOp::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.group; auto attr = dict.get("group"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `group` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Tcgen05CommitOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.group; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("group", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Tcgen05CommitOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.group.getAsOpaquePointer())); } std::optional Tcgen05CommitOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "group") return prop.group; return std::nullopt; } void Tcgen05CommitOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "group") { prop.group = ::llvm::dyn_cast_or_null>(value); return; } } void Tcgen05CommitOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.group) attrs.append("group", prop.group); } ::llvm::LogicalResult Tcgen05CommitOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getGroupAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(attr, "group", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05CommitOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.group))) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05CommitOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.group); } ::mlir::NVVM::CTAGroupKind Tcgen05CommitOp::getGroup() { auto attr = getGroupAttr(); return attr.getValue(); } void Tcgen05CommitOp::setGroup(::mlir::NVVM::CTAGroupKind attrValue) { getProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05CommitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, /*optional*/::mlir::Value multicastMask, ::mlir::NVVM::CTAGroupKindAttr group) { odsState.addOperands(addr); if (multicastMask) odsState.addOperands(multicastMask); if (group) { odsState.getOrAddProperties().group = group; } } Tcgen05CommitOp Tcgen05CommitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, /*optional*/::mlir::Value multicastMask, ::mlir::NVVM::CTAGroupKindAttr group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(multicastMask), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05CommitOp Tcgen05CommitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, /*optional*/::mlir::Value multicastMask, ::mlir::NVVM::CTAGroupKindAttr group) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(multicastMask), std::forward(group)); } void Tcgen05CommitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value multicastMask, ::mlir::NVVM::CTAGroupKindAttr group) { odsState.addOperands(addr); if (multicastMask) odsState.addOperands(multicastMask); if (group) { odsState.getOrAddProperties().group = group; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05CommitOp Tcgen05CommitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value multicastMask, ::mlir::NVVM::CTAGroupKindAttr group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(multicastMask), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05CommitOp Tcgen05CommitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value multicastMask, ::mlir::NVVM::CTAGroupKindAttr group) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(multicastMask), std::forward(group)); } void Tcgen05CommitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value addr, /*optional*/::mlir::Value multicastMask, ::mlir::NVVM::CTAGroupKind group) { odsState.addOperands(addr); if (multicastMask) odsState.addOperands(multicastMask); odsState.getOrAddProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), group); } Tcgen05CommitOp Tcgen05CommitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value addr, /*optional*/::mlir::Value multicastMask, ::mlir::NVVM::CTAGroupKind group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(addr), std::forward(multicastMask), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05CommitOp Tcgen05CommitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value addr, /*optional*/::mlir::Value multicastMask, ::mlir::NVVM::CTAGroupKind group) { return create(builder, builder.getLoc(), std::forward(addr), std::forward(multicastMask), std::forward(group)); } void Tcgen05CommitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value multicastMask, ::mlir::NVVM::CTAGroupKind group) { odsState.addOperands(addr); if (multicastMask) odsState.addOperands(multicastMask); odsState.getOrAddProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), group); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05CommitOp Tcgen05CommitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value multicastMask, ::mlir::NVVM::CTAGroupKind group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(addr), std::forward(multicastMask), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05CommitOp Tcgen05CommitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value addr, /*optional*/::mlir::Value multicastMask, ::mlir::NVVM::CTAGroupKind group) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(addr), std::forward(multicastMask), std::forward(group)); } void Tcgen05CommitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05CommitOp Tcgen05CommitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05CommitOp Tcgen05CommitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05CommitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05CommitOp Tcgen05CommitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05CommitOp Tcgen05CommitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Tcgen05CommitOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.group) properties.group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), CTAGroupKind::CTA_1); } ::llvm::LogicalResult Tcgen05CommitOp::verifyInvariantsImpl() { auto tblgen_group = getProperties().group; (void)tblgen_group; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(*this, tblgen_group, "group"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps39(*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_NVVMOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05CommitOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult Tcgen05CommitOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand addrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> addrOperands(&addrRawOperand, 1); ::llvm::SMLoc addrOperandsLoc; (void)addrOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> multicastMaskOperands; ::llvm::SMLoc multicastMaskOperandsLoc; (void)multicastMaskOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { if (parser.parseKeyword("multicast_mask")) return ::mlir::failure(); if (parser.parseEqual()) return ::mlir::failure(); { multicastMaskOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); multicastMaskOperands.push_back(operand); } } } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.resolveOperands(::llvm::concat(addrOperands, multicastMaskOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05CommitOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getAddr(); if (getMulticastMask()) { _odsPrinter << ","; _odsPrinter << ' ' << "multicast_mask"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getMulticastMask()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getGroupAttr(); if(attr && (attr == ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), CTAGroupKind::CTA_1))) elidedAttrs.push_back("group"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05CommitOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05CommitOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05CpOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05CpOpGenericAdaptorBase::Tcgen05CpOpGenericAdaptorBase(Tcgen05CpOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::Tcgen05CpShape Tcgen05CpOpGenericAdaptorBase::getShape() { auto attr = getShapeAttr(); return attr.getValue(); } ::mlir::NVVM::CTAGroupKindAttr Tcgen05CpOpGenericAdaptorBase::getGroupAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::CTAGroupKindAttr>(getProperties().group); return attr; } ::mlir::NVVM::CTAGroupKind Tcgen05CpOpGenericAdaptorBase::getGroup() { auto attr = getGroupAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05CpMulticastAttr Tcgen05CpOpGenericAdaptorBase::getMulticastAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::Tcgen05CpMulticastAttr>(getProperties().multicast); return attr; } ::mlir::NVVM::Tcgen05CpMulticast Tcgen05CpOpGenericAdaptorBase::getMulticast() { auto attr = getMulticastAttr(); return attr.getValue(); } ::std::optional<::mlir::NVVM::Tcgen05CpSrcFormat> Tcgen05CpOpGenericAdaptorBase::getSrcFormat() { auto attr = getSrcFormatAttr(); return attr ? ::std::optional<::mlir::NVVM::Tcgen05CpSrcFormat>(attr.getValue()) : (::std::nullopt); } } // namespace detail Tcgen05CpOpAdaptor::Tcgen05CpOpAdaptor(Tcgen05CpOp op) : Tcgen05CpOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05CpOpAdaptor::verify(::mlir::Location loc) { auto tblgen_group = getProperties().group; (void)tblgen_group; auto tblgen_multicast = getProperties().multicast; (void)tblgen_multicast; auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitError(loc, "'nvvm.tcgen05.cp' op requires attribute 'shape'"); auto tblgen_srcFormat = getProperties().srcFormat; (void)tblgen_srcFormat; if (tblgen_shape && !((::llvm::isa<::mlir::NVVM::Tcgen05CpShapeAttr>(tblgen_shape)))) return emitError(loc, "'nvvm.tcgen05.cp' op attribute 'shape' failed to satisfy constraint: tcgen05 cp shapes"); if (tblgen_group && !((::llvm::isa<::mlir::NVVM::CTAGroupKindAttr>(tblgen_group)))) return emitError(loc, "'nvvm.tcgen05.cp' op attribute 'group' failed to satisfy constraint: NVVM CTA group kind"); if (tblgen_multicast && !((::llvm::isa<::mlir::NVVM::Tcgen05CpMulticastAttr>(tblgen_multicast)))) return emitError(loc, "'nvvm.tcgen05.cp' op attribute 'multicast' failed to satisfy constraint: tcgen05 cp multicast"); if (tblgen_srcFormat && !((::llvm::isa<::mlir::NVVM::Tcgen05CpSrcFormatAttr>(tblgen_srcFormat)))) return emitError(loc, "'nvvm.tcgen05.cp' op attribute 'srcFormat' failed to satisfy constraint: tcgen05 cp source format"); return ::mlir::success(); } ::llvm::LogicalResult Tcgen05CpOp::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.group; auto attr = dict.get("group"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `group` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.multicast; auto attr = dict.get("multicast"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `multicast` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.shape; auto attr = dict.get("shape"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `shape` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.srcFormat; auto attr = dict.get("srcFormat"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `srcFormat` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Tcgen05CpOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.group; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("group", propStorage)); } { const auto &propStorage = prop.multicast; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("multicast", propStorage)); } { const auto &propStorage = prop.shape; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("shape", propStorage)); } { const auto &propStorage = prop.srcFormat; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("srcFormat", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Tcgen05CpOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.group.getAsOpaquePointer()), llvm::hash_value(prop.multicast.getAsOpaquePointer()), llvm::hash_value(prop.shape.getAsOpaquePointer()), llvm::hash_value(prop.srcFormat.getAsOpaquePointer())); } std::optional Tcgen05CpOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "group") return prop.group; if (name == "multicast") return prop.multicast; if (name == "shape") return prop.shape; if (name == "srcFormat") return prop.srcFormat; return std::nullopt; } void Tcgen05CpOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "group") { prop.group = ::llvm::dyn_cast_or_null>(value); return; } if (name == "multicast") { prop.multicast = ::llvm::dyn_cast_or_null>(value); return; } if (name == "shape") { prop.shape = ::llvm::dyn_cast_or_null>(value); return; } if (name == "srcFormat") { prop.srcFormat = ::llvm::dyn_cast_or_null>(value); return; } } void Tcgen05CpOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.group) attrs.append("group", prop.group); if (prop.multicast) attrs.append("multicast", prop.multicast); if (prop.shape) attrs.append("shape", prop.shape); if (prop.srcFormat) attrs.append("srcFormat", prop.srcFormat); } ::llvm::LogicalResult Tcgen05CpOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getGroupAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(attr, "group", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getMulticastAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps54(attr, "multicast", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getShapeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps53(attr, "shape", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSrcFormatAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps55(attr, "srcFormat", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05CpOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.group))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.multicast))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.shape))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.srcFormat))) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05CpOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.group); writer.writeOptionalAttribute(prop.multicast); writer.writeAttribute(prop.shape); writer.writeOptionalAttribute(prop.srcFormat); } ::mlir::NVVM::Tcgen05CpShape Tcgen05CpOp::getShape() { auto attr = getShapeAttr(); return attr.getValue(); } ::mlir::NVVM::CTAGroupKind Tcgen05CpOp::getGroup() { auto attr = getGroupAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05CpMulticast Tcgen05CpOp::getMulticast() { auto attr = getMulticastAttr(); return attr.getValue(); } ::std::optional<::mlir::NVVM::Tcgen05CpSrcFormat> Tcgen05CpOp::getSrcFormat() { auto attr = getSrcFormatAttr(); return attr ? ::std::optional<::mlir::NVVM::Tcgen05CpSrcFormat>(attr.getValue()) : (::std::nullopt); } void Tcgen05CpOp::setShape(::mlir::NVVM::Tcgen05CpShape attrValue) { getProperties().shape = ::mlir::NVVM::Tcgen05CpShapeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05CpOp::setGroup(::mlir::NVVM::CTAGroupKind attrValue) { getProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05CpOp::setMulticast(::mlir::NVVM::Tcgen05CpMulticast attrValue) { getProperties().multicast = ::mlir::NVVM::Tcgen05CpMulticastAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05CpOp::setSrcFormat(::std::optional<::mlir::NVVM::Tcgen05CpSrcFormat> attrValue) { auto &odsProp = getProperties().srcFormat; if (attrValue) odsProp = ::mlir::NVVM::Tcgen05CpSrcFormatAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void Tcgen05CpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05CpShapeAttr shape, ::mlir::NVVM::CTAGroupKindAttr group, ::mlir::NVVM::Tcgen05CpMulticastAttr multicast, /*optional*/::mlir::NVVM::Tcgen05CpSrcFormatAttr srcFormat, ::mlir::Value taddr, ::mlir::Value smem_desc) { odsState.addOperands(taddr); odsState.addOperands(smem_desc); odsState.getOrAddProperties().shape = shape; if (group) { odsState.getOrAddProperties().group = group; } if (multicast) { odsState.getOrAddProperties().multicast = multicast; } if (srcFormat) { odsState.getOrAddProperties().srcFormat = srcFormat; } } Tcgen05CpOp Tcgen05CpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05CpShapeAttr shape, ::mlir::NVVM::CTAGroupKindAttr group, ::mlir::NVVM::Tcgen05CpMulticastAttr multicast, /*optional*/::mlir::NVVM::Tcgen05CpSrcFormatAttr srcFormat, ::mlir::Value taddr, ::mlir::Value smem_desc) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(shape), std::forward(group), std::forward(multicast), std::forward(srcFormat), std::forward(taddr), std::forward(smem_desc)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05CpOp Tcgen05CpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05CpShapeAttr shape, ::mlir::NVVM::CTAGroupKindAttr group, ::mlir::NVVM::Tcgen05CpMulticastAttr multicast, /*optional*/::mlir::NVVM::Tcgen05CpSrcFormatAttr srcFormat, ::mlir::Value taddr, ::mlir::Value smem_desc) { return create(builder, builder.getLoc(), std::forward(shape), std::forward(group), std::forward(multicast), std::forward(srcFormat), std::forward(taddr), std::forward(smem_desc)); } void Tcgen05CpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05CpShapeAttr shape, ::mlir::NVVM::CTAGroupKindAttr group, ::mlir::NVVM::Tcgen05CpMulticastAttr multicast, /*optional*/::mlir::NVVM::Tcgen05CpSrcFormatAttr srcFormat, ::mlir::Value taddr, ::mlir::Value smem_desc) { odsState.addOperands(taddr); odsState.addOperands(smem_desc); odsState.getOrAddProperties().shape = shape; if (group) { odsState.getOrAddProperties().group = group; } if (multicast) { odsState.getOrAddProperties().multicast = multicast; } if (srcFormat) { odsState.getOrAddProperties().srcFormat = srcFormat; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05CpOp Tcgen05CpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05CpShapeAttr shape, ::mlir::NVVM::CTAGroupKindAttr group, ::mlir::NVVM::Tcgen05CpMulticastAttr multicast, /*optional*/::mlir::NVVM::Tcgen05CpSrcFormatAttr srcFormat, ::mlir::Value taddr, ::mlir::Value smem_desc) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(shape), std::forward(group), std::forward(multicast), std::forward(srcFormat), std::forward(taddr), std::forward(smem_desc)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05CpOp Tcgen05CpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05CpShapeAttr shape, ::mlir::NVVM::CTAGroupKindAttr group, ::mlir::NVVM::Tcgen05CpMulticastAttr multicast, /*optional*/::mlir::NVVM::Tcgen05CpSrcFormatAttr srcFormat, ::mlir::Value taddr, ::mlir::Value smem_desc) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(shape), std::forward(group), std::forward(multicast), std::forward(srcFormat), std::forward(taddr), std::forward(smem_desc)); } void Tcgen05CpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05CpShape shape, ::mlir::NVVM::CTAGroupKind group, ::mlir::NVVM::Tcgen05CpMulticast multicast, /*optional*/::mlir::NVVM::Tcgen05CpSrcFormatAttr srcFormat, ::mlir::Value taddr, ::mlir::Value smem_desc) { odsState.addOperands(taddr); odsState.addOperands(smem_desc); odsState.getOrAddProperties().shape = ::mlir::NVVM::Tcgen05CpShapeAttr::get(odsBuilder.getContext(), shape); odsState.getOrAddProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), group); odsState.getOrAddProperties().multicast = ::mlir::NVVM::Tcgen05CpMulticastAttr::get(odsBuilder.getContext(), multicast); if (srcFormat) { odsState.getOrAddProperties().srcFormat = srcFormat; } } Tcgen05CpOp Tcgen05CpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05CpShape shape, ::mlir::NVVM::CTAGroupKind group, ::mlir::NVVM::Tcgen05CpMulticast multicast, /*optional*/::mlir::NVVM::Tcgen05CpSrcFormatAttr srcFormat, ::mlir::Value taddr, ::mlir::Value smem_desc) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(shape), std::forward(group), std::forward(multicast), std::forward(srcFormat), std::forward(taddr), std::forward(smem_desc)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05CpOp Tcgen05CpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05CpShape shape, ::mlir::NVVM::CTAGroupKind group, ::mlir::NVVM::Tcgen05CpMulticast multicast, /*optional*/::mlir::NVVM::Tcgen05CpSrcFormatAttr srcFormat, ::mlir::Value taddr, ::mlir::Value smem_desc) { return create(builder, builder.getLoc(), std::forward(shape), std::forward(group), std::forward(multicast), std::forward(srcFormat), std::forward(taddr), std::forward(smem_desc)); } void Tcgen05CpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05CpShape shape, ::mlir::NVVM::CTAGroupKind group, ::mlir::NVVM::Tcgen05CpMulticast multicast, /*optional*/::mlir::NVVM::Tcgen05CpSrcFormatAttr srcFormat, ::mlir::Value taddr, ::mlir::Value smem_desc) { odsState.addOperands(taddr); odsState.addOperands(smem_desc); odsState.getOrAddProperties().shape = ::mlir::NVVM::Tcgen05CpShapeAttr::get(odsBuilder.getContext(), shape); odsState.getOrAddProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), group); odsState.getOrAddProperties().multicast = ::mlir::NVVM::Tcgen05CpMulticastAttr::get(odsBuilder.getContext(), multicast); if (srcFormat) { odsState.getOrAddProperties().srcFormat = srcFormat; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05CpOp Tcgen05CpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05CpShape shape, ::mlir::NVVM::CTAGroupKind group, ::mlir::NVVM::Tcgen05CpMulticast multicast, /*optional*/::mlir::NVVM::Tcgen05CpSrcFormatAttr srcFormat, ::mlir::Value taddr, ::mlir::Value smem_desc) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(shape), std::forward(group), std::forward(multicast), std::forward(srcFormat), std::forward(taddr), std::forward(smem_desc)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05CpOp Tcgen05CpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05CpShape shape, ::mlir::NVVM::CTAGroupKind group, ::mlir::NVVM::Tcgen05CpMulticast multicast, /*optional*/::mlir::NVVM::Tcgen05CpSrcFormatAttr srcFormat, ::mlir::Value taddr, ::mlir::Value smem_desc) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(shape), std::forward(group), std::forward(multicast), std::forward(srcFormat), std::forward(taddr), std::forward(smem_desc)); } void Tcgen05CpOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05CpOp Tcgen05CpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05CpOp Tcgen05CpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05CpOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05CpOp Tcgen05CpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05CpOp Tcgen05CpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Tcgen05CpOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.group) properties.group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), CTAGroupKind::CTA_1); if (!properties.multicast) properties.multicast = ::mlir::NVVM::Tcgen05CpMulticastAttr::get(odsBuilder.getContext(), Tcgen05CpMulticast::NONE); } ::llvm::LogicalResult Tcgen05CpOp::verifyInvariantsImpl() { auto tblgen_group = getProperties().group; (void)tblgen_group; auto tblgen_multicast = getProperties().multicast; (void)tblgen_multicast; auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitOpError("requires attribute 'shape'"); auto tblgen_srcFormat = getProperties().srcFormat; (void)tblgen_srcFormat; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps53(*this, tblgen_shape, "shape"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(*this, tblgen_group, "group"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps54(*this, tblgen_multicast, "multicast"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps55(*this, tblgen_srcFormat, "srcFormat"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05CpOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult Tcgen05CpOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand taddrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> taddrOperands(&taddrRawOperand, 1); ::llvm::SMLoc taddrOperandsLoc; (void)taddrOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand smem_descRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> smem_descOperands(&smem_descRawOperand, 1); ::llvm::SMLoc smem_descOperandsLoc; (void)smem_descOperandsLoc; taddrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(taddrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); smem_descOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(smem_descRawOperand)) 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(); } ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::LLVM::LLVMPointerType>(6); ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(64); if (parser.resolveOperands(taddrOperands, odsBuildableType0, taddrOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(smem_descOperands, odsBuildableType1, smem_descOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05CpOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getTaddr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSmemDesc(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getGroupAttr(); if(attr && (attr == ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), CTAGroupKind::CTA_1))) elidedAttrs.push_back("group"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getMulticastAttr(); if(attr && (attr == ::mlir::NVVM::Tcgen05CpMulticastAttr::get(odsBuilder.getContext(), Tcgen05CpMulticast::NONE))) elidedAttrs.push_back("multicast"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05CpOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05CpOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05DeallocOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05DeallocOpGenericAdaptorBase::Tcgen05DeallocOpGenericAdaptorBase(Tcgen05DeallocOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::CTAGroupKindAttr Tcgen05DeallocOpGenericAdaptorBase::getGroupAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::CTAGroupKindAttr>(getProperties().group); return attr; } ::mlir::NVVM::CTAGroupKind Tcgen05DeallocOpGenericAdaptorBase::getGroup() { auto attr = getGroupAttr(); return attr.getValue(); } } // namespace detail Tcgen05DeallocOpAdaptor::Tcgen05DeallocOpAdaptor(Tcgen05DeallocOp op) : Tcgen05DeallocOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05DeallocOpAdaptor::verify(::mlir::Location loc) { auto tblgen_group = getProperties().group; (void)tblgen_group; if (tblgen_group && !((::llvm::isa<::mlir::NVVM::CTAGroupKindAttr>(tblgen_group)))) return emitError(loc, "'nvvm.tcgen05.dealloc' op attribute 'group' failed to satisfy constraint: NVVM CTA group kind"); return ::mlir::success(); } ::llvm::LogicalResult Tcgen05DeallocOp::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.group; auto attr = dict.get("group"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `group` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Tcgen05DeallocOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.group; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("group", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Tcgen05DeallocOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.group.getAsOpaquePointer())); } std::optional Tcgen05DeallocOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "group") return prop.group; return std::nullopt; } void Tcgen05DeallocOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "group") { prop.group = ::llvm::dyn_cast_or_null>(value); return; } } void Tcgen05DeallocOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.group) attrs.append("group", prop.group); } ::llvm::LogicalResult Tcgen05DeallocOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getGroupAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(attr, "group", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05DeallocOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.group))) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05DeallocOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.group); } ::mlir::NVVM::CTAGroupKind Tcgen05DeallocOp::getGroup() { auto attr = getGroupAttr(); return attr.getValue(); } void Tcgen05DeallocOp::setGroup(::mlir::NVVM::CTAGroupKind attrValue) { getProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05DeallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value taddr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKindAttr group) { odsState.addOperands(taddr); odsState.addOperands(nCols); if (group) { odsState.getOrAddProperties().group = group; } } Tcgen05DeallocOp Tcgen05DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value taddr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKindAttr group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(taddr), std::forward(nCols), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05DeallocOp Tcgen05DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value taddr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKindAttr group) { return create(builder, builder.getLoc(), std::forward(taddr), std::forward(nCols), std::forward(group)); } void Tcgen05DeallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value taddr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKindAttr group) { odsState.addOperands(taddr); odsState.addOperands(nCols); if (group) { odsState.getOrAddProperties().group = group; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05DeallocOp Tcgen05DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value taddr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKindAttr group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(taddr), std::forward(nCols), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05DeallocOp Tcgen05DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value taddr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKindAttr group) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(taddr), std::forward(nCols), std::forward(group)); } void Tcgen05DeallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value taddr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKind group) { odsState.addOperands(taddr); odsState.addOperands(nCols); odsState.getOrAddProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), group); } Tcgen05DeallocOp Tcgen05DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value taddr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKind group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(taddr), std::forward(nCols), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05DeallocOp Tcgen05DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value taddr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKind group) { return create(builder, builder.getLoc(), std::forward(taddr), std::forward(nCols), std::forward(group)); } void Tcgen05DeallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value taddr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKind group) { odsState.addOperands(taddr); odsState.addOperands(nCols); odsState.getOrAddProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), group); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05DeallocOp Tcgen05DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value taddr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKind group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(taddr), std::forward(nCols), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05DeallocOp Tcgen05DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value taddr, ::mlir::Value nCols, ::mlir::NVVM::CTAGroupKind group) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(taddr), std::forward(nCols), std::forward(group)); } void Tcgen05DeallocOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05DeallocOp Tcgen05DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05DeallocOp Tcgen05DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05DeallocOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05DeallocOp Tcgen05DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05DeallocOp Tcgen05DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Tcgen05DeallocOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.group) properties.group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), CTAGroupKind::CTA_1); } ::llvm::LogicalResult Tcgen05DeallocOp::verifyInvariantsImpl() { auto tblgen_group = getProperties().group; (void)tblgen_group; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(*this, tblgen_group, "group"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05DeallocOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult Tcgen05DeallocOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand taddrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> taddrOperands(&taddrRawOperand, 1); ::llvm::SMLoc taddrOperandsLoc; (void)taddrOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand nColsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> nColsOperands(&nColsRawOperand, 1); ::llvm::SMLoc nColsOperandsLoc; (void)nColsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; taddrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(taddrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); nColsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(nColsRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.resolveOperands(::llvm::concat(taddrOperands, nColsOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05DeallocOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getTaddr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getNCols(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getGroupAttr(); if(attr && (attr == ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), CTAGroupKind::CTA_1))) elidedAttrs.push_back("group"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05DeallocOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05DeallocOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05FenceOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05FenceOpGenericAdaptorBase::Tcgen05FenceOpGenericAdaptorBase(Tcgen05FenceOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::Tcgen05FenceKind Tcgen05FenceOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } } // namespace detail Tcgen05FenceOpAdaptor::Tcgen05FenceOpAdaptor(Tcgen05FenceOp op) : Tcgen05FenceOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05FenceOpAdaptor::verify(::mlir::Location loc) { auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'nvvm.tcgen05.fence' op requires attribute 'kind'"); if (tblgen_kind && !((::llvm::isa<::mlir::NVVM::Tcgen05FenceKindAttr>(tblgen_kind)))) return emitError(loc, "'nvvm.tcgen05.fence' op attribute 'kind' failed to satisfy constraint: NVVM Tcgen05 fence kind"); return ::mlir::success(); } ::llvm::LogicalResult Tcgen05FenceOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Tcgen05FenceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Tcgen05FenceOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.kind.getAsOpaquePointer())); } std::optional Tcgen05FenceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "kind") return prop.kind; return std::nullopt; } void Tcgen05FenceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } } void Tcgen05FenceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.kind) attrs.append("kind", prop.kind); } ::llvm::LogicalResult Tcgen05FenceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps56(attr, "kind", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05FenceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.kind))) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05FenceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.kind); } ::mlir::NVVM::Tcgen05FenceKind Tcgen05FenceOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } void Tcgen05FenceOp::setKind(::mlir::NVVM::Tcgen05FenceKind attrValue) { getProperties().kind = ::mlir::NVVM::Tcgen05FenceKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05FenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05FenceKindAttr kind) { odsState.getOrAddProperties().kind = kind; } Tcgen05FenceOp Tcgen05FenceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05FenceKindAttr kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05FenceOp Tcgen05FenceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05FenceKindAttr kind) { return create(builder, builder.getLoc(), std::forward(kind)); } void Tcgen05FenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05FenceKindAttr kind) { odsState.getOrAddProperties().kind = kind; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05FenceOp Tcgen05FenceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05FenceKindAttr kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05FenceOp Tcgen05FenceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05FenceKindAttr kind) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind)); } void Tcgen05FenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05FenceKind kind) { odsState.getOrAddProperties().kind = ::mlir::NVVM::Tcgen05FenceKindAttr::get(odsBuilder.getContext(), kind); } Tcgen05FenceOp Tcgen05FenceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05FenceKind kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05FenceOp Tcgen05FenceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05FenceKind kind) { return create(builder, builder.getLoc(), std::forward(kind)); } void Tcgen05FenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05FenceKind kind) { odsState.getOrAddProperties().kind = ::mlir::NVVM::Tcgen05FenceKindAttr::get(odsBuilder.getContext(), kind); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05FenceOp Tcgen05FenceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05FenceKind kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05FenceOp Tcgen05FenceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05FenceKind kind) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind)); } void Tcgen05FenceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05FenceOp Tcgen05FenceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05FenceOp Tcgen05FenceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05FenceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05FenceOp Tcgen05FenceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05FenceOp Tcgen05FenceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult Tcgen05FenceOp::verifyInvariantsImpl() { auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps56(*this, tblgen_kind, "kind"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult Tcgen05FenceOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult Tcgen05FenceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::Tcgen05FenceKindAttr kindAttr; if (parser.parseCustomAttributeWithFallback(kindAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (kindAttr) result.getOrAddProperties().kind = kindAttr; { 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 Tcgen05FenceOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getKindAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("kind"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05FenceOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05FenceOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05LdOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05LdOpGenericAdaptorBase::Tcgen05LdOpGenericAdaptorBase(Tcgen05LdOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair Tcgen05LdOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::UnitAttr Tcgen05LdOpGenericAdaptorBase::getPackAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().pack); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool Tcgen05LdOpGenericAdaptorBase::getPack() { auto attr = getPackAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::mlir::NVVM::Tcgen05LdStShape Tcgen05LdOpGenericAdaptorBase::getShape() { auto attr = getShapeAttr(); return attr.getValue(); } } // namespace detail Tcgen05LdOpAdaptor::Tcgen05LdOpAdaptor(Tcgen05LdOp op) : Tcgen05LdOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05LdOpAdaptor::verify(::mlir::Location loc) { auto tblgen_pack = getProperties().pack; (void)tblgen_pack; auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitError(loc, "'nvvm.tcgen05.ld' op requires attribute 'shape'"); if (tblgen_pack && !((::llvm::isa<::mlir::UnitAttr>(tblgen_pack)))) return emitError(loc, "'nvvm.tcgen05.ld' op attribute 'pack' failed to satisfy constraint: unit attribute"); if (tblgen_shape && !((::llvm::isa<::mlir::NVVM::Tcgen05LdStShapeAttr>(tblgen_shape)))) return emitError(loc, "'nvvm.tcgen05.ld' op attribute 'shape' failed to satisfy constraint: allowed 32-bit signless integer cases: 0, 1, 2, 3, 4"); return ::mlir::success(); } std::pair Tcgen05LdOp::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 Tcgen05LdOp::getOffsetMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult Tcgen05LdOp::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.pack; auto attr = dict.get("pack"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `pack` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.shape; auto attr = dict.get("shape"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `shape` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Tcgen05LdOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.pack; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("pack", propStorage)); } { const auto &propStorage = prop.shape; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("shape", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Tcgen05LdOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.pack.getAsOpaquePointer()), llvm::hash_value(prop.shape.getAsOpaquePointer())); } std::optional Tcgen05LdOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "pack") return prop.pack; if (name == "shape") return prop.shape; return std::nullopt; } void Tcgen05LdOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "pack") { prop.pack = ::llvm::dyn_cast_or_null>(value); return; } if (name == "shape") { prop.shape = ::llvm::dyn_cast_or_null>(value); return; } } void Tcgen05LdOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.pack) attrs.append("pack", prop.pack); if (prop.shape) attrs.append("shape", prop.shape); } ::llvm::LogicalResult Tcgen05LdOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getPackAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "pack", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getShapeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps57(attr, "shape", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05LdOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.pack))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.shape))) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05LdOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.pack); writer.writeAttribute(prop.shape); } bool Tcgen05LdOp::getPack() { auto attr = getPackAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::mlir::NVVM::Tcgen05LdStShape Tcgen05LdOp::getShape() { auto attr = getShapeAttr(); return attr.getValue(); } void Tcgen05LdOp::setPack(bool attrValue) { auto &odsProp = getProperties().pack; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void Tcgen05LdOp::setShape(::mlir::NVVM::Tcgen05LdStShape attrValue) { getProperties().shape = ::mlir::NVVM::Tcgen05LdStShapeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05LdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::UnitAttr pack, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::Value tmemAddr, /*optional*/::mlir::Value offset) { odsState.addOperands(tmemAddr); if (offset) odsState.addOperands(offset); if (pack) { odsState.getOrAddProperties().pack = pack; } odsState.getOrAddProperties().shape = shape; odsState.addTypes(res); } Tcgen05LdOp Tcgen05LdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::UnitAttr pack, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::Value tmemAddr, /*optional*/::mlir::Value offset) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(pack), std::forward(shape), std::forward(tmemAddr), std::forward(offset)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05LdOp Tcgen05LdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::UnitAttr pack, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::Value tmemAddr, /*optional*/::mlir::Value offset) { return create(builder, builder.getLoc(), std::forward(res), std::forward(pack), std::forward(shape), std::forward(tmemAddr), std::forward(offset)); } void Tcgen05LdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr pack, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::Value tmemAddr, /*optional*/::mlir::Value offset) { odsState.addOperands(tmemAddr); if (offset) odsState.addOperands(offset); if (pack) { odsState.getOrAddProperties().pack = pack; } odsState.getOrAddProperties().shape = shape; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05LdOp Tcgen05LdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr pack, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::Value tmemAddr, /*optional*/::mlir::Value offset) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(pack), std::forward(shape), std::forward(tmemAddr), std::forward(offset)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05LdOp Tcgen05LdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr pack, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::Value tmemAddr, /*optional*/::mlir::Value offset) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(pack), std::forward(shape), std::forward(tmemAddr), std::forward(offset)); } void Tcgen05LdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/bool pack, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::Value tmemAddr, /*optional*/::mlir::Value offset) { odsState.addOperands(tmemAddr); if (offset) odsState.addOperands(offset); if (pack) { odsState.getOrAddProperties().pack = ((pack) ? odsBuilder.getUnitAttr() : nullptr); } odsState.getOrAddProperties().shape = ::mlir::NVVM::Tcgen05LdStShapeAttr::get(odsBuilder.getContext(), shape); odsState.addTypes(res); } Tcgen05LdOp Tcgen05LdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/bool pack, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::Value tmemAddr, /*optional*/::mlir::Value offset) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(pack), std::forward(shape), std::forward(tmemAddr), std::forward(offset)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05LdOp Tcgen05LdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/bool pack, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::Value tmemAddr, /*optional*/::mlir::Value offset) { return create(builder, builder.getLoc(), std::forward(res), std::forward(pack), std::forward(shape), std::forward(tmemAddr), std::forward(offset)); } void Tcgen05LdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/bool pack, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::Value tmemAddr, /*optional*/::mlir::Value offset) { odsState.addOperands(tmemAddr); if (offset) odsState.addOperands(offset); if (pack) { odsState.getOrAddProperties().pack = ((pack) ? odsBuilder.getUnitAttr() : nullptr); } odsState.getOrAddProperties().shape = ::mlir::NVVM::Tcgen05LdStShapeAttr::get(odsBuilder.getContext(), shape); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05LdOp Tcgen05LdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/bool pack, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::Value tmemAddr, /*optional*/::mlir::Value offset) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(pack), std::forward(shape), std::forward(tmemAddr), std::forward(offset)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05LdOp Tcgen05LdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/bool pack, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::Value tmemAddr, /*optional*/::mlir::Value offset) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(pack), std::forward(shape), std::forward(tmemAddr), std::forward(offset)); } void Tcgen05LdOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05LdOp Tcgen05LdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05LdOp Tcgen05LdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05LdOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05LdOp Tcgen05LdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05LdOp Tcgen05LdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult Tcgen05LdOp::verifyInvariantsImpl() { auto tblgen_pack = getProperties().pack; (void)tblgen_pack; auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitOpError("requires attribute 'shape'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_pack, "pack"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps57(*this, tblgen_shape, "shape"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*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_NVVMOps4(*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_NVVMOps41(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05LdOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult Tcgen05LdOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand tmemAddrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tmemAddrOperands(&tmemAddrRawOperand, 1); ::llvm::SMLoc tmemAddrOperandsLoc; (void)tmemAddrOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> offsetOperands; ::llvm::SMLoc offsetOperandsLoc; (void)offsetOperandsLoc; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); tmemAddrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(tmemAddrRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { offsetOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); offsetOperands.push_back(operand); } } } if (::mlir::succeeded(parser.parseOptionalKeyword("pack"))) { result.getOrAddProperties().pack = parser.getBuilder().getUnitAttr(); } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::LLVM::LLVMPointerType>(6); ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(64); result.addTypes(resTypes); if (parser.resolveOperands(tmemAddrOperands, odsBuildableType0, tmemAddrOperandsLoc, result.operands)) return ::mlir::failure(); if (!offsetOperands.empty()) { if (parser.resolveOperands(offsetOperands, odsBuildableType1, offsetOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void Tcgen05LdOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getTmemAddr(); if (getOffset()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getOffset()) _odsPrinter << value; } if ((getPackAttr() && getPackAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "pack"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("pack"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getPackAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("pack"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05LdOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05LdOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05LdRedOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05LdRedOpGenericAdaptorBase::Tcgen05LdRedOpGenericAdaptorBase(Tcgen05LdRedOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair Tcgen05LdRedOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::NVVM::Tcgen05LdStShape Tcgen05LdRedOpGenericAdaptorBase::getShape() { auto attr = getShapeAttr(); return attr.getValue(); } ::mlir::NVVM::ReductionKind Tcgen05LdRedOpGenericAdaptorBase::getOp() { auto attr = getOpAttr(); return attr.getValue(); } ::mlir::UnitAttr Tcgen05LdRedOpGenericAdaptorBase::getAbsAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().abs); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool Tcgen05LdRedOpGenericAdaptorBase::getAbs() { auto attr = getAbsAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::mlir::UnitAttr Tcgen05LdRedOpGenericAdaptorBase::getNanAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nan); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool Tcgen05LdRedOpGenericAdaptorBase::getNan() { auto attr = getNanAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail Tcgen05LdRedOpAdaptor::Tcgen05LdRedOpAdaptor(Tcgen05LdRedOp op) : Tcgen05LdRedOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05LdRedOpAdaptor::verify(::mlir::Location loc) { auto tblgen_abs = getProperties().abs; (void)tblgen_abs; auto tblgen_nan = getProperties().nan; (void)tblgen_nan; auto tblgen_op = getProperties().op; (void)tblgen_op; if (!tblgen_op) return emitError(loc, "'nvvm.tcgen05.ld.red' op requires attribute 'op'"); auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitError(loc, "'nvvm.tcgen05.ld.red' op requires attribute 'shape'"); if (tblgen_shape && !((::llvm::isa<::mlir::NVVM::Tcgen05LdStShapeAttr>(tblgen_shape)))) return emitError(loc, "'nvvm.tcgen05.ld.red' op attribute 'shape' failed to satisfy constraint: allowed 32-bit signless integer cases: 0, 1, 2, 3, 4"); if (tblgen_op && !((::llvm::isa<::mlir::NVVM::ReductionKindAttr>(tblgen_op)))) return emitError(loc, "'nvvm.tcgen05.ld.red' op attribute 'op' failed to satisfy constraint: NVVM Reduction Kind attribute"); if (tblgen_abs && !((::llvm::isa<::mlir::UnitAttr>(tblgen_abs)))) return emitError(loc, "'nvvm.tcgen05.ld.red' op attribute 'abs' failed to satisfy constraint: unit attribute"); if (tblgen_nan && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nan)))) return emitError(loc, "'nvvm.tcgen05.ld.red' op attribute 'nan' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } void Tcgen05LdRedOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { auto resultGroup0 = getODSResults(0); if (!resultGroup0.empty()) setNameFn(*resultGroup0.begin(), "data"); auto resultGroup1 = getODSResults(1); if (!resultGroup1.empty()) setNameFn(*resultGroup1.begin(), "redVal"); } std::pair Tcgen05LdRedOp::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 Tcgen05LdRedOp::getOffsetMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult Tcgen05LdRedOp::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.abs; auto attr = dict.get("abs"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `abs` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.nan; auto attr = dict.get("nan"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `nan` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.op; auto attr = dict.get("op"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `op` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.shape; auto attr = dict.get("shape"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `shape` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Tcgen05LdRedOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.abs; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("abs", propStorage)); } { const auto &propStorage = prop.nan; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("nan", propStorage)); } { const auto &propStorage = prop.op; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("op", propStorage)); } { const auto &propStorage = prop.shape; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("shape", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Tcgen05LdRedOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.abs.getAsOpaquePointer()), llvm::hash_value(prop.nan.getAsOpaquePointer()), llvm::hash_value(prop.op.getAsOpaquePointer()), llvm::hash_value(prop.shape.getAsOpaquePointer())); } std::optional Tcgen05LdRedOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "abs") return prop.abs; if (name == "nan") return prop.nan; if (name == "op") return prop.op; if (name == "shape") return prop.shape; return std::nullopt; } void Tcgen05LdRedOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "abs") { prop.abs = ::llvm::dyn_cast_or_null>(value); return; } if (name == "nan") { prop.nan = ::llvm::dyn_cast_or_null>(value); return; } if (name == "op") { prop.op = ::llvm::dyn_cast_or_null>(value); return; } if (name == "shape") { prop.shape = ::llvm::dyn_cast_or_null>(value); return; } } void Tcgen05LdRedOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.abs) attrs.append("abs", prop.abs); if (prop.nan) attrs.append("nan", prop.nan); if (prop.op) attrs.append("op", prop.op); if (prop.shape) attrs.append("shape", prop.shape); } ::llvm::LogicalResult Tcgen05LdRedOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAbsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "abs", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNanAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "nan", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getOpAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps50(attr, "op", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getShapeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps57(attr, "shape", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05LdRedOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.abs))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.nan))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.op))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.shape))) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05LdRedOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.abs); writer.writeOptionalAttribute(prop.nan); writer.writeAttribute(prop.op); writer.writeAttribute(prop.shape); } ::mlir::NVVM::Tcgen05LdStShape Tcgen05LdRedOp::getShape() { auto attr = getShapeAttr(); return attr.getValue(); } ::mlir::NVVM::ReductionKind Tcgen05LdRedOp::getOp() { auto attr = getOpAttr(); return attr.getValue(); } bool Tcgen05LdRedOp::getAbs() { auto attr = getAbsAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } bool Tcgen05LdRedOp::getNan() { auto attr = getNanAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void Tcgen05LdRedOp::setShape(::mlir::NVVM::Tcgen05LdStShape attrValue) { getProperties().shape = ::mlir::NVVM::Tcgen05LdStShapeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05LdRedOp::setOp(::mlir::NVVM::ReductionKind attrValue) { getProperties().op = ::mlir::NVVM::ReductionKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05LdRedOp::setAbs(bool attrValue) { auto &odsProp = getProperties().abs; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void Tcgen05LdRedOp::setNan(bool attrValue) { auto &odsProp = getProperties().nan; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void Tcgen05LdRedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type data, ::mlir::Type redVal, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::NVVM::ReductionKindAttr op, /*optional*/::mlir::UnitAttr abs, /*optional*/::mlir::UnitAttr nan, ::mlir::Value addr, /*optional*/::mlir::Value offset) { odsState.addOperands(addr); if (offset) odsState.addOperands(offset); odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().op = op; if (abs) { odsState.getOrAddProperties().abs = abs; } if (nan) { odsState.getOrAddProperties().nan = nan; } odsState.addTypes(data); odsState.addTypes(redVal); } Tcgen05LdRedOp Tcgen05LdRedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type data, ::mlir::Type redVal, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::NVVM::ReductionKindAttr op, /*optional*/::mlir::UnitAttr abs, /*optional*/::mlir::UnitAttr nan, ::mlir::Value addr, /*optional*/::mlir::Value offset) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(data), std::forward(redVal), std::forward(shape), std::forward(op), std::forward(abs), std::forward(nan), std::forward(addr), std::forward(offset)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05LdRedOp Tcgen05LdRedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type data, ::mlir::Type redVal, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::NVVM::ReductionKindAttr op, /*optional*/::mlir::UnitAttr abs, /*optional*/::mlir::UnitAttr nan, ::mlir::Value addr, /*optional*/::mlir::Value offset) { return create(builder, builder.getLoc(), std::forward(data), std::forward(redVal), std::forward(shape), std::forward(op), std::forward(abs), std::forward(nan), std::forward(addr), std::forward(offset)); } void Tcgen05LdRedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::NVVM::ReductionKindAttr op, /*optional*/::mlir::UnitAttr abs, /*optional*/::mlir::UnitAttr nan, ::mlir::Value addr, /*optional*/::mlir::Value offset) { odsState.addOperands(addr); if (offset) odsState.addOperands(offset); odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().op = op; if (abs) { odsState.getOrAddProperties().abs = abs; } if (nan) { odsState.getOrAddProperties().nan = nan; } assert(resultTypes.size() == 2u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05LdRedOp Tcgen05LdRedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::NVVM::ReductionKindAttr op, /*optional*/::mlir::UnitAttr abs, /*optional*/::mlir::UnitAttr nan, ::mlir::Value addr, /*optional*/::mlir::Value offset) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(shape), std::forward(op), std::forward(abs), std::forward(nan), std::forward(addr), std::forward(offset)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05LdRedOp Tcgen05LdRedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::NVVM::ReductionKindAttr op, /*optional*/::mlir::UnitAttr abs, /*optional*/::mlir::UnitAttr nan, ::mlir::Value addr, /*optional*/::mlir::Value offset) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(shape), std::forward(op), std::forward(abs), std::forward(nan), std::forward(addr), std::forward(offset)); } void Tcgen05LdRedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type data, ::mlir::Type redVal, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::NVVM::ReductionKind op, /*optional*/bool abs, /*optional*/bool nan, ::mlir::Value addr, /*optional*/::mlir::Value offset) { odsState.addOperands(addr); if (offset) odsState.addOperands(offset); odsState.getOrAddProperties().shape = ::mlir::NVVM::Tcgen05LdStShapeAttr::get(odsBuilder.getContext(), shape); odsState.getOrAddProperties().op = ::mlir::NVVM::ReductionKindAttr::get(odsBuilder.getContext(), op); if (abs) { odsState.getOrAddProperties().abs = ((abs) ? odsBuilder.getUnitAttr() : nullptr); } if (nan) { odsState.getOrAddProperties().nan = ((nan) ? odsBuilder.getUnitAttr() : nullptr); } odsState.addTypes(data); odsState.addTypes(redVal); } Tcgen05LdRedOp Tcgen05LdRedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type data, ::mlir::Type redVal, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::NVVM::ReductionKind op, /*optional*/bool abs, /*optional*/bool nan, ::mlir::Value addr, /*optional*/::mlir::Value offset) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(data), std::forward(redVal), std::forward(shape), std::forward(op), std::forward(abs), std::forward(nan), std::forward(addr), std::forward(offset)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05LdRedOp Tcgen05LdRedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type data, ::mlir::Type redVal, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::NVVM::ReductionKind op, /*optional*/bool abs, /*optional*/bool nan, ::mlir::Value addr, /*optional*/::mlir::Value offset) { return create(builder, builder.getLoc(), std::forward(data), std::forward(redVal), std::forward(shape), std::forward(op), std::forward(abs), std::forward(nan), std::forward(addr), std::forward(offset)); } void Tcgen05LdRedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::NVVM::ReductionKind op, /*optional*/bool abs, /*optional*/bool nan, ::mlir::Value addr, /*optional*/::mlir::Value offset) { odsState.addOperands(addr); if (offset) odsState.addOperands(offset); odsState.getOrAddProperties().shape = ::mlir::NVVM::Tcgen05LdStShapeAttr::get(odsBuilder.getContext(), shape); odsState.getOrAddProperties().op = ::mlir::NVVM::ReductionKindAttr::get(odsBuilder.getContext(), op); if (abs) { odsState.getOrAddProperties().abs = ((abs) ? odsBuilder.getUnitAttr() : nullptr); } if (nan) { odsState.getOrAddProperties().nan = ((nan) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 2u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05LdRedOp Tcgen05LdRedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::NVVM::ReductionKind op, /*optional*/bool abs, /*optional*/bool nan, ::mlir::Value addr, /*optional*/::mlir::Value offset) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(shape), std::forward(op), std::forward(abs), std::forward(nan), std::forward(addr), std::forward(offset)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05LdRedOp Tcgen05LdRedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::NVVM::ReductionKind op, /*optional*/bool abs, /*optional*/bool nan, ::mlir::Value addr, /*optional*/::mlir::Value offset) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(shape), std::forward(op), std::forward(abs), std::forward(nan), std::forward(addr), std::forward(offset)); } void Tcgen05LdRedOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 2u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05LdRedOp Tcgen05LdRedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05LdRedOp Tcgen05LdRedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05LdRedOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 2u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05LdRedOp Tcgen05LdRedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05LdRedOp Tcgen05LdRedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult Tcgen05LdRedOp::verifyInvariantsImpl() { auto tblgen_abs = getProperties().abs; (void)tblgen_abs; auto tblgen_nan = getProperties().nan; (void)tblgen_nan; auto tblgen_op = getProperties().op; (void)tblgen_op; if (!tblgen_op) return emitOpError("requires attribute 'op'"); auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitOpError("requires attribute 'shape'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps57(*this, tblgen_shape, "shape"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps50(*this, tblgen_op, "op"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_abs, "abs"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_nan, "nan"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*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_NVVMOps4(*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_NVVMOps42(*this, v.getType(), "result", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSResults(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps37(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05LdRedOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult Tcgen05LdRedOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::ReductionKindAttr opAttr; ::mlir::OpAsmParser::UnresolvedOperand addrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> addrOperands(&addrRawOperand, 1); ::llvm::SMLoc addrOperandsLoc; (void)addrOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> offsetOperands; ::llvm::SMLoc offsetOperandsLoc; (void)offsetOperandsLoc; ::mlir::Type dataRawType{}; ::llvm::ArrayRef<::mlir::Type> dataTypes(&dataRawType, 1); ::mlir::Type redValRawType{}; ::llvm::ArrayRef<::mlir::Type> redValTypes(&redValRawType, 1); if (parser.parseCustomAttributeWithFallback(opAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (opAttr) result.getOrAddProperties().op = opAttr; addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { offsetOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); offsetOperands.push_back(operand); } } } { 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::VectorType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); dataRawType = type; } if (parser.parseComma()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); redValRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::LLVM::LLVMPointerType>(6); ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(64); result.addTypes(dataTypes); result.addTypes(redValTypes); if (parser.resolveOperands(addrOperands, odsBuildableType0, addrOperandsLoc, result.operands)) return ::mlir::failure(); if (!offsetOperands.empty()) { if (parser.resolveOperands(offsetOperands, odsBuildableType1, offsetOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void Tcgen05LdRedOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getOpAttr()); _odsPrinter << ' '; _odsPrinter << getAddr(); if (getOffset()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getOffset()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("op"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getAbsAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("abs"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getNanAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("nan"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getData().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; { auto type = getRedVal().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05LdRedOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05LdRedOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05MMABlockScaleOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05MMABlockScaleOpGenericAdaptorBase::Tcgen05MMABlockScaleOpGenericAdaptorBase(Tcgen05MMABlockScaleOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::Tcgen05MMAKind Tcgen05MMABlockScaleOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::mlir::NVVM::CTAGroupKind Tcgen05MMABlockScaleOpGenericAdaptorBase::getCtaGroup() { auto attr = getCtaGroupAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMABlockScaleAttr Tcgen05MMABlockScaleOpGenericAdaptorBase::getBlockScaleAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::Tcgen05MMABlockScaleAttr>(getProperties().blockScale); return attr; } ::mlir::NVVM::Tcgen05MMABlockScale Tcgen05MMABlockScaleOpGenericAdaptorBase::getBlockScale() { auto attr = getBlockScaleAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMACollectorOpAttr Tcgen05MMABlockScaleOpGenericAdaptorBase::getCollectorOpAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::Tcgen05MMACollectorOpAttr>(getProperties().collectorOp); return attr; } ::mlir::NVVM::Tcgen05MMACollectorOp Tcgen05MMABlockScaleOpGenericAdaptorBase::getCollectorOp() { auto attr = getCollectorOpAttr(); return attr.getValue(); } } // namespace detail Tcgen05MMABlockScaleOpAdaptor::Tcgen05MMABlockScaleOpAdaptor(Tcgen05MMABlockScaleOp op) : Tcgen05MMABlockScaleOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05MMABlockScaleOpAdaptor::verify(::mlir::Location loc) { auto tblgen_blockScale = getProperties().blockScale; (void)tblgen_blockScale; auto tblgen_collectorOp = getProperties().collectorOp; (void)tblgen_collectorOp; auto tblgen_ctaGroup = getProperties().ctaGroup; (void)tblgen_ctaGroup; if (!tblgen_ctaGroup) return emitError(loc, "'nvvm.tcgen05.mma.block_scale' op requires attribute 'ctaGroup'"); auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'nvvm.tcgen05.mma.block_scale' op requires attribute 'kind'"); if (tblgen_kind && !(((::llvm::isa<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind))) && (((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::MXF8F6F4)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::MXF4)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::MXF4NVF4))))) return emitError(loc, "'nvvm.tcgen05.mma.block_scale' op attribute 'kind' failed to satisfy constraint: tcgen05 MMA Supported Types whose value is one of {mxf8f6f4, mxf4, mxf4nvf4}"); if (tblgen_ctaGroup && !((::llvm::isa<::mlir::NVVM::CTAGroupKindAttr>(tblgen_ctaGroup)))) return emitError(loc, "'nvvm.tcgen05.mma.block_scale' op attribute 'ctaGroup' failed to satisfy constraint: NVVM CTA group kind"); if (tblgen_blockScale && !((::llvm::isa<::mlir::NVVM::Tcgen05MMABlockScaleAttr>(tblgen_blockScale)))) return emitError(loc, "'nvvm.tcgen05.mma.block_scale' op attribute 'blockScale' failed to satisfy constraint: tcgen05.mma block scale attribute"); if (tblgen_collectorOp && !((::llvm::isa<::mlir::NVVM::Tcgen05MMACollectorOpAttr>(tblgen_collectorOp)))) return emitError(loc, "'nvvm.tcgen05.mma.block_scale' op attribute 'collectorOp' failed to satisfy constraint: tcgen05.mma Collector Buffer Operation"); return ::mlir::success(); } ::llvm::LogicalResult Tcgen05MMABlockScaleOp::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.blockScale; auto attr = dict.get("blockScale"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `blockScale` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.collectorOp; auto attr = dict.get("collectorOp"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `collectorOp` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.ctaGroup; auto attr = dict.get("ctaGroup"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ctaGroup` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Tcgen05MMABlockScaleOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.blockScale; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("blockScale", propStorage)); } { const auto &propStorage = prop.collectorOp; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("collectorOp", propStorage)); } { const auto &propStorage = prop.ctaGroup; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ctaGroup", propStorage)); } { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Tcgen05MMABlockScaleOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.blockScale.getAsOpaquePointer()), llvm::hash_value(prop.collectorOp.getAsOpaquePointer()), llvm::hash_value(prop.ctaGroup.getAsOpaquePointer()), llvm::hash_value(prop.kind.getAsOpaquePointer())); } std::optional Tcgen05MMABlockScaleOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "blockScale") return prop.blockScale; if (name == "collectorOp") return prop.collectorOp; if (name == "ctaGroup") return prop.ctaGroup; if (name == "kind") return prop.kind; return std::nullopt; } void Tcgen05MMABlockScaleOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "blockScale") { prop.blockScale = ::llvm::dyn_cast_or_null>(value); return; } if (name == "collectorOp") { prop.collectorOp = ::llvm::dyn_cast_or_null>(value); return; } if (name == "ctaGroup") { prop.ctaGroup = ::llvm::dyn_cast_or_null>(value); return; } if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } } void Tcgen05MMABlockScaleOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.blockScale) attrs.append("blockScale", prop.blockScale); if (prop.collectorOp) attrs.append("collectorOp", prop.collectorOp); if (prop.ctaGroup) attrs.append("ctaGroup", prop.ctaGroup); if (prop.kind) attrs.append("kind", prop.kind); } ::llvm::LogicalResult Tcgen05MMABlockScaleOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getBlockScaleAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps59(attr, "blockScale", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getCollectorOpAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps60(attr, "collectorOp", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getCtaGroupAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(attr, "ctaGroup", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps58(attr, "kind", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05MMABlockScaleOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.blockScale))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.collectorOp))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.ctaGroup))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.kind))) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05MMABlockScaleOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.blockScale); writer.writeOptionalAttribute(prop.collectorOp); writer.writeAttribute(prop.ctaGroup); writer.writeAttribute(prop.kind); } ::mlir::NVVM::Tcgen05MMAKind Tcgen05MMABlockScaleOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::mlir::NVVM::CTAGroupKind Tcgen05MMABlockScaleOp::getCtaGroup() { auto attr = getCtaGroupAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMABlockScale Tcgen05MMABlockScaleOp::getBlockScale() { auto attr = getBlockScaleAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMACollectorOp Tcgen05MMABlockScaleOp::getCollectorOp() { auto attr = getCollectorOpAttr(); return attr.getValue(); } void Tcgen05MMABlockScaleOp::setKind(::mlir::NVVM::Tcgen05MMAKind attrValue) { getProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMABlockScaleOp::setCtaGroup(::mlir::NVVM::CTAGroupKind attrValue) { getProperties().ctaGroup = ::mlir::NVVM::CTAGroupKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMABlockScaleOp::setBlockScale(::mlir::NVVM::Tcgen05MMABlockScale attrValue) { getProperties().blockScale = ::mlir::NVVM::Tcgen05MMABlockScaleAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMABlockScaleOp::setCollectorOp(::mlir::NVVM::Tcgen05MMACollectorOp attrValue) { getProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMABlockScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScaleAttr blockScale, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value scaleA, ::mlir::Value scaleB) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); odsState.addOperands(scaleA); odsState.addOperands(scaleB); odsState.getOrAddProperties().kind = kind; odsState.getOrAddProperties().ctaGroup = ctaGroup; if (blockScale) { odsState.getOrAddProperties().blockScale = blockScale; } if (collectorOp) { odsState.getOrAddProperties().collectorOp = collectorOp; } } Tcgen05MMABlockScaleOp Tcgen05MMABlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScaleAttr blockScale, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value scaleA, ::mlir::Value scaleB) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind), std::forward(ctaGroup), std::forward(blockScale), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(scaleA), std::forward(scaleB)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMABlockScaleOp Tcgen05MMABlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScaleAttr blockScale, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value scaleA, ::mlir::Value scaleB) { return create(builder, builder.getLoc(), std::forward(kind), std::forward(ctaGroup), std::forward(blockScale), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(scaleA), std::forward(scaleB)); } void Tcgen05MMABlockScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScaleAttr blockScale, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value scaleA, ::mlir::Value scaleB) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); odsState.addOperands(scaleA); odsState.addOperands(scaleB); odsState.getOrAddProperties().kind = kind; odsState.getOrAddProperties().ctaGroup = ctaGroup; if (blockScale) { odsState.getOrAddProperties().blockScale = blockScale; } if (collectorOp) { odsState.getOrAddProperties().collectorOp = collectorOp; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05MMABlockScaleOp Tcgen05MMABlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScaleAttr blockScale, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value scaleA, ::mlir::Value scaleB) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind), std::forward(ctaGroup), std::forward(blockScale), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(scaleA), std::forward(scaleB)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMABlockScaleOp Tcgen05MMABlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScaleAttr blockScale, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value scaleA, ::mlir::Value scaleB) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind), std::forward(ctaGroup), std::forward(blockScale), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(scaleA), std::forward(scaleB)); } void Tcgen05MMABlockScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScale blockScale, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value scaleA, ::mlir::Value scaleB) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); odsState.addOperands(scaleA); odsState.addOperands(scaleB); odsState.getOrAddProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(odsBuilder.getContext(), kind); odsState.getOrAddProperties().ctaGroup = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), ctaGroup); odsState.getOrAddProperties().blockScale = ::mlir::NVVM::Tcgen05MMABlockScaleAttr::get(odsBuilder.getContext(), blockScale); odsState.getOrAddProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), collectorOp); } Tcgen05MMABlockScaleOp Tcgen05MMABlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScale blockScale, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value scaleA, ::mlir::Value scaleB) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind), std::forward(ctaGroup), std::forward(blockScale), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(scaleA), std::forward(scaleB)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMABlockScaleOp Tcgen05MMABlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScale blockScale, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value scaleA, ::mlir::Value scaleB) { return create(builder, builder.getLoc(), std::forward(kind), std::forward(ctaGroup), std::forward(blockScale), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(scaleA), std::forward(scaleB)); } void Tcgen05MMABlockScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScale blockScale, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value scaleA, ::mlir::Value scaleB) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); odsState.addOperands(scaleA); odsState.addOperands(scaleB); odsState.getOrAddProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(odsBuilder.getContext(), kind); odsState.getOrAddProperties().ctaGroup = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), ctaGroup); odsState.getOrAddProperties().blockScale = ::mlir::NVVM::Tcgen05MMABlockScaleAttr::get(odsBuilder.getContext(), blockScale); odsState.getOrAddProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), collectorOp); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05MMABlockScaleOp Tcgen05MMABlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScale blockScale, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value scaleA, ::mlir::Value scaleB) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind), std::forward(ctaGroup), std::forward(blockScale), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(scaleA), std::forward(scaleB)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMABlockScaleOp Tcgen05MMABlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScale blockScale, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value scaleA, ::mlir::Value scaleB) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind), std::forward(ctaGroup), std::forward(blockScale), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(scaleA), std::forward(scaleB)); } void Tcgen05MMABlockScaleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 7u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05MMABlockScaleOp Tcgen05MMABlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMABlockScaleOp Tcgen05MMABlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05MMABlockScaleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 7u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05MMABlockScaleOp Tcgen05MMABlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMABlockScaleOp Tcgen05MMABlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Tcgen05MMABlockScaleOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.blockScale) properties.blockScale = ::mlir::NVVM::Tcgen05MMABlockScaleAttr::get(odsBuilder.getContext(), Tcgen05MMABlockScale::DEFAULT); if (!properties.collectorOp) properties.collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), Tcgen05MMACollectorOp::DISCARD); } ::llvm::LogicalResult Tcgen05MMABlockScaleOp::verifyInvariantsImpl() { auto tblgen_blockScale = getProperties().blockScale; (void)tblgen_blockScale; auto tblgen_collectorOp = getProperties().collectorOp; (void)tblgen_collectorOp; auto tblgen_ctaGroup = getProperties().ctaGroup; (void)tblgen_ctaGroup; if (!tblgen_ctaGroup) return emitOpError("requires attribute 'ctaGroup'"); auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps58(*this, tblgen_kind, "kind"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(*this, tblgen_ctaGroup, "ctaGroup"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps59(*this, tblgen_blockScale, "blockScale"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps60(*this, tblgen_collectorOp, "collectorOp"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps43(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps23(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup5 = getODSOperands(5); for (auto v : valueGroup5) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup6 = getODSOperands(6); for (auto v : valueGroup6) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05MMABlockScaleOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult Tcgen05MMABlockScaleOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand matrixDRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixDOperands(&matrixDRawOperand, 1); ::llvm::SMLoc matrixDOperandsLoc; (void)matrixDOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand matrixARawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixAOperands(&matrixARawOperand, 1); ::llvm::SMLoc matrixAOperandsLoc; (void)matrixAOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand matrixBRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixBOperands(&matrixBRawOperand, 1); ::llvm::SMLoc matrixBOperandsLoc; (void)matrixBOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand idescRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> idescOperands(&idescRawOperand, 1); ::llvm::SMLoc idescOperandsLoc; (void)idescOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand enableInputDRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> enableInputDOperands(&enableInputDRawOperand, 1); ::llvm::SMLoc enableInputDOperandsLoc; (void)enableInputDOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand scaleARawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> scaleAOperands(&scaleARawOperand, 1); ::llvm::SMLoc scaleAOperandsLoc; (void)scaleAOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand scaleBRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> scaleBOperands(&scaleBRawOperand, 1); ::llvm::SMLoc scaleBOperandsLoc; (void)scaleBOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; matrixDOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixDRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); matrixAOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixARawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); matrixBOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixBRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); idescOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(idescRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); enableInputDOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(enableInputDRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); scaleAOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(scaleARawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); scaleBOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(scaleBRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); if (parser.resolveOperands(::llvm::concat(matrixDOperands, matrixAOperands, matrixBOperands, idescOperands, enableInputDOperands, scaleAOperands, scaleBOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05MMABlockScaleOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getMatrixD(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMatrixA(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMatrixB(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getIdesc(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getEnableInputD(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getScaleA(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getScaleB(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getBlockScaleAttr(); if(attr && (attr == ::mlir::NVVM::Tcgen05MMABlockScaleAttr::get(odsBuilder.getContext(), Tcgen05MMABlockScale::DEFAULT))) elidedAttrs.push_back("blockScale"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getCollectorOpAttr(); if(attr && (attr == ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), Tcgen05MMACollectorOp::DISCARD))) elidedAttrs.push_back("collectorOp"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' ' << "("; _odsPrinter << getOperation()->getOperandTypes(); _odsPrinter << ")"; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05MMABlockScaleOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05MMABlockScaleOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05MMAOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05MMAOpGenericAdaptorBase::Tcgen05MMAOpGenericAdaptorBase(Tcgen05MMAOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair Tcgen05MMAOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::NVVM::Tcgen05MMAKind Tcgen05MMAOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::mlir::NVVM::CTAGroupKind Tcgen05MMAOpGenericAdaptorBase::getCtaGroup() { auto attr = getCtaGroupAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMACollectorOpAttr Tcgen05MMAOpGenericAdaptorBase::getCollectorOpAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::Tcgen05MMACollectorOpAttr>(getProperties().collectorOp); return attr; } ::mlir::NVVM::Tcgen05MMACollectorOp Tcgen05MMAOpGenericAdaptorBase::getCollectorOp() { auto attr = getCollectorOpAttr(); return attr.getValue(); } ::mlir::UnitAttr Tcgen05MMAOpGenericAdaptorBase::getAShiftAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().aShift); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool Tcgen05MMAOpGenericAdaptorBase::getAShift() { auto attr = getAShiftAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail Tcgen05MMAOpAdaptor::Tcgen05MMAOpAdaptor(Tcgen05MMAOp op) : Tcgen05MMAOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05MMAOpAdaptor::verify(::mlir::Location loc) { auto tblgen_aShift = getProperties().aShift; (void)tblgen_aShift; auto tblgen_collectorOp = getProperties().collectorOp; (void)tblgen_collectorOp; auto tblgen_ctaGroup = getProperties().ctaGroup; (void)tblgen_ctaGroup; if (!tblgen_ctaGroup) return emitError(loc, "'nvvm.tcgen05.mma' op requires attribute 'ctaGroup'"); auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'nvvm.tcgen05.mma' op requires attribute 'kind'"); if (tblgen_kind && !(((::llvm::isa<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind))) && (((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::F16)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::TF32)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::F8F6F4)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::I8))))) return emitError(loc, "'nvvm.tcgen05.mma' op attribute 'kind' failed to satisfy constraint: tcgen05 MMA Supported Types whose value is one of {f16, tf32, f8f6f4, i8}"); if (tblgen_ctaGroup && !((::llvm::isa<::mlir::NVVM::CTAGroupKindAttr>(tblgen_ctaGroup)))) return emitError(loc, "'nvvm.tcgen05.mma' op attribute 'ctaGroup' failed to satisfy constraint: NVVM CTA group kind"); if (tblgen_collectorOp && !((::llvm::isa<::mlir::NVVM::Tcgen05MMACollectorOpAttr>(tblgen_collectorOp)))) return emitError(loc, "'nvvm.tcgen05.mma' op attribute 'collectorOp' failed to satisfy constraint: tcgen05.mma Collector Buffer Operation"); if (tblgen_aShift && !((::llvm::isa<::mlir::UnitAttr>(tblgen_aShift)))) return emitError(loc, "'nvvm.tcgen05.mma' op attribute 'aShift' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } std::pair Tcgen05MMAOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange Tcgen05MMAOp::getScaleInputDMutable() { 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 Tcgen05MMAOp::getDisableOutputLaneMutable() { 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 Tcgen05MMAOp::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.aShift; auto attr = dict.get("aShift"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `aShift` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.collectorOp; auto attr = dict.get("collectorOp"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `collectorOp` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.ctaGroup; auto attr = dict.get("ctaGroup"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ctaGroup` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } { 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 Tcgen05MMAOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.aShift; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("aShift", propStorage)); } { const auto &propStorage = prop.collectorOp; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("collectorOp", propStorage)); } { const auto &propStorage = prop.ctaGroup; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ctaGroup", propStorage)); } { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", 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 Tcgen05MMAOp::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.aShift.getAsOpaquePointer()), llvm::hash_value(prop.collectorOp.getAsOpaquePointer()), llvm::hash_value(prop.ctaGroup.getAsOpaquePointer()), llvm::hash_value(prop.kind.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional Tcgen05MMAOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "aShift") return prop.aShift; if (name == "collectorOp") return prop.collectorOp; if (name == "ctaGroup") return prop.ctaGroup; if (name == "kind") return prop.kind; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void Tcgen05MMAOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "aShift") { prop.aShift = ::llvm::dyn_cast_or_null>(value); return; } if (name == "collectorOp") { prop.collectorOp = ::llvm::dyn_cast_or_null>(value); return; } if (name == "ctaGroup") { prop.ctaGroup = ::llvm::dyn_cast_or_null>(value); return; } if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void Tcgen05MMAOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.aShift) attrs.append("aShift", prop.aShift); if (prop.collectorOp) attrs.append("collectorOp", prop.collectorOp); if (prop.ctaGroup) attrs.append("ctaGroup", prop.ctaGroup); if (prop.kind) attrs.append("kind", prop.kind); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult Tcgen05MMAOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAShiftAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "aShift", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getCollectorOpAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps60(attr, "collectorOp", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getCtaGroupAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(attr, "ctaGroup", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps61(attr, "kind", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05MMAOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.aShift))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.collectorOp))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.ctaGroup))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.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(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void Tcgen05MMAOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.aShift); writer.writeOptionalAttribute(prop.collectorOp); writer.writeAttribute(prop.ctaGroup); writer.writeAttribute(prop.kind); 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)); ; } } ::mlir::NVVM::Tcgen05MMAKind Tcgen05MMAOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::mlir::NVVM::CTAGroupKind Tcgen05MMAOp::getCtaGroup() { auto attr = getCtaGroupAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMACollectorOp Tcgen05MMAOp::getCollectorOp() { auto attr = getCollectorOpAttr(); return attr.getValue(); } bool Tcgen05MMAOp::getAShift() { auto attr = getAShiftAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void Tcgen05MMAOp::setKind(::mlir::NVVM::Tcgen05MMAKind attrValue) { getProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMAOp::setCtaGroup(::mlir::NVVM::CTAGroupKind attrValue) { getProperties().ctaGroup = ::mlir::NVVM::CTAGroupKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMAOp::setCollectorOp(::mlir::NVVM::Tcgen05MMACollectorOp attrValue) { getProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMAOp::setAShift(bool attrValue) { auto &odsProp = getProperties().aShift; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void Tcgen05MMAOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, /*optional*/::mlir::UnitAttr aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); if (scaleInputD) odsState.addOperands(scaleInputD); if (disableOutputLane) odsState.addOperands(disableOutputLane); ::llvm::copy(::llvm::ArrayRef({1, 1, 1, 1, 1, (scaleInputD ? 1 : 0), (disableOutputLane ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().kind = kind; odsState.getOrAddProperties().ctaGroup = ctaGroup; if (collectorOp) { odsState.getOrAddProperties().collectorOp = collectorOp; } if (aShift) { odsState.getOrAddProperties().aShift = aShift; } } Tcgen05MMAOp Tcgen05MMAOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, /*optional*/::mlir::UnitAttr aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind), std::forward(ctaGroup), std::forward(collectorOp), std::forward(aShift), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(scaleInputD), std::forward(disableOutputLane)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAOp Tcgen05MMAOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, /*optional*/::mlir::UnitAttr aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { return create(builder, builder.getLoc(), std::forward(kind), std::forward(ctaGroup), std::forward(collectorOp), std::forward(aShift), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(scaleInputD), std::forward(disableOutputLane)); } void Tcgen05MMAOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, /*optional*/::mlir::UnitAttr aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); if (scaleInputD) odsState.addOperands(scaleInputD); if (disableOutputLane) odsState.addOperands(disableOutputLane); ::llvm::copy(::llvm::ArrayRef({1, 1, 1, 1, 1, (scaleInputD ? 1 : 0), (disableOutputLane ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().kind = kind; odsState.getOrAddProperties().ctaGroup = ctaGroup; if (collectorOp) { odsState.getOrAddProperties().collectorOp = collectorOp; } if (aShift) { odsState.getOrAddProperties().aShift = aShift; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05MMAOp Tcgen05MMAOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, /*optional*/::mlir::UnitAttr aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind), std::forward(ctaGroup), std::forward(collectorOp), std::forward(aShift), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(scaleInputD), std::forward(disableOutputLane)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAOp Tcgen05MMAOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, /*optional*/::mlir::UnitAttr aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind), std::forward(ctaGroup), std::forward(collectorOp), std::forward(aShift), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(scaleInputD), std::forward(disableOutputLane)); } void Tcgen05MMAOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, /*optional*/bool aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); if (scaleInputD) odsState.addOperands(scaleInputD); if (disableOutputLane) odsState.addOperands(disableOutputLane); ::llvm::copy(::llvm::ArrayRef({1, 1, 1, 1, 1, (scaleInputD ? 1 : 0), (disableOutputLane ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(odsBuilder.getContext(), kind); odsState.getOrAddProperties().ctaGroup = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), ctaGroup); odsState.getOrAddProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), collectorOp); if (aShift) { odsState.getOrAddProperties().aShift = ((aShift) ? odsBuilder.getUnitAttr() : nullptr); } } Tcgen05MMAOp Tcgen05MMAOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, /*optional*/bool aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind), std::forward(ctaGroup), std::forward(collectorOp), std::forward(aShift), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(scaleInputD), std::forward(disableOutputLane)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAOp Tcgen05MMAOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, /*optional*/bool aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { return create(builder, builder.getLoc(), std::forward(kind), std::forward(ctaGroup), std::forward(collectorOp), std::forward(aShift), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(scaleInputD), std::forward(disableOutputLane)); } void Tcgen05MMAOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, /*optional*/bool aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); if (scaleInputD) odsState.addOperands(scaleInputD); if (disableOutputLane) odsState.addOperands(disableOutputLane); ::llvm::copy(::llvm::ArrayRef({1, 1, 1, 1, 1, (scaleInputD ? 1 : 0), (disableOutputLane ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(odsBuilder.getContext(), kind); odsState.getOrAddProperties().ctaGroup = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), ctaGroup); odsState.getOrAddProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), collectorOp); if (aShift) { odsState.getOrAddProperties().aShift = ((aShift) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05MMAOp Tcgen05MMAOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, /*optional*/bool aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind), std::forward(ctaGroup), std::forward(collectorOp), std::forward(aShift), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(scaleInputD), std::forward(disableOutputLane)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAOp Tcgen05MMAOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, /*optional*/bool aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind), std::forward(ctaGroup), std::forward(collectorOp), std::forward(aShift), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(scaleInputD), std::forward(disableOutputLane)); } void Tcgen05MMAOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 5u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05MMAOp Tcgen05MMAOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAOp Tcgen05MMAOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05MMAOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 5u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05MMAOp Tcgen05MMAOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAOp Tcgen05MMAOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Tcgen05MMAOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.collectorOp) properties.collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), Tcgen05MMACollectorOp::DISCARD); } ::llvm::LogicalResult Tcgen05MMAOp::verifyInvariantsImpl() { auto tblgen_aShift = getProperties().aShift; (void)tblgen_aShift; auto tblgen_collectorOp = getProperties().collectorOp; (void)tblgen_collectorOp; auto tblgen_ctaGroup = getProperties().ctaGroup; (void)tblgen_ctaGroup; if (!tblgen_ctaGroup) return emitOpError("requires attribute 'ctaGroup'"); auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps61(*this, tblgen_kind, "kind"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(*this, tblgen_ctaGroup, "ctaGroup"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps60(*this, tblgen_collectorOp, "collectorOp"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_aShift, "aShift"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps43(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps23(*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_NVVMOps4(*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_NVVMOps44(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05MMAOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult Tcgen05MMAOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand matrixDRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixDOperands(&matrixDRawOperand, 1); ::llvm::SMLoc matrixDOperandsLoc; (void)matrixDOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand matrixARawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixAOperands(&matrixARawOperand, 1); ::llvm::SMLoc matrixAOperandsLoc; (void)matrixAOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand matrixBRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixBOperands(&matrixBRawOperand, 1); ::llvm::SMLoc matrixBOperandsLoc; (void)matrixBOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand idescRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> idescOperands(&idescRawOperand, 1); ::llvm::SMLoc idescOperandsLoc; (void)idescOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand enableInputDRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> enableInputDOperands(&enableInputDRawOperand, 1); ::llvm::SMLoc enableInputDOperandsLoc; (void)enableInputDOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> scaleInputDOperands; ::llvm::SMLoc scaleInputDOperandsLoc; (void)scaleInputDOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> disableOutputLaneOperands; ::llvm::SMLoc disableOutputLaneOperandsLoc; (void)disableOutputLaneOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; matrixDOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixDRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); matrixAOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixARawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); matrixBOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixBRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); idescOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(idescRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); enableInputDOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(enableInputDRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("scale"))) { if (parser.parseEqual()) return ::mlir::failure(); { scaleInputDOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); scaleInputDOperands.push_back(operand); } } } if (::mlir::succeeded(parser.parseOptionalKeyword("mask"))) { if (parser.parseEqual()) return ::mlir::failure(); { disableOutputLaneOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); disableOutputLaneOperands.push_back(operand); } } } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); ::llvm::copy(::llvm::ArrayRef({1, 1, 1, 1, 1, static_cast(scaleInputDOperands.size()), static_cast(disableOutputLaneOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); if (parser.resolveOperands(::llvm::concat(matrixDOperands, matrixAOperands, matrixBOperands, idescOperands, enableInputDOperands, scaleInputDOperands, disableOutputLaneOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05MMAOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getMatrixD(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMatrixA(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMatrixB(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getIdesc(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getEnableInputD(); if (getScaleInputD()) { _odsPrinter << ' ' << "scale"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getScaleInputD()) _odsPrinter << value; } if (getDisableOutputLane()) { _odsPrinter << ' ' << "mask"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getDisableOutputLane()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getCollectorOpAttr(); if(attr && (attr == ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), Tcgen05MMACollectorOp::DISCARD))) elidedAttrs.push_back("collectorOp"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getAShiftAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("aShift"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' ' << "("; _odsPrinter << getOperation()->getOperandTypes(); _odsPrinter << ")"; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05MMAOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05MMAOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05MMASparseBlockScaleOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05MMASparseBlockScaleOpGenericAdaptorBase::Tcgen05MMASparseBlockScaleOpGenericAdaptorBase(Tcgen05MMASparseBlockScaleOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::Tcgen05MMAKind Tcgen05MMASparseBlockScaleOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::mlir::NVVM::CTAGroupKind Tcgen05MMASparseBlockScaleOpGenericAdaptorBase::getCtaGroup() { auto attr = getCtaGroupAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMABlockScaleAttr Tcgen05MMASparseBlockScaleOpGenericAdaptorBase::getBlockScaleAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::Tcgen05MMABlockScaleAttr>(getProperties().blockScale); return attr; } ::mlir::NVVM::Tcgen05MMABlockScale Tcgen05MMASparseBlockScaleOpGenericAdaptorBase::getBlockScale() { auto attr = getBlockScaleAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMACollectorOpAttr Tcgen05MMASparseBlockScaleOpGenericAdaptorBase::getCollectorOpAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::Tcgen05MMACollectorOpAttr>(getProperties().collectorOp); return attr; } ::mlir::NVVM::Tcgen05MMACollectorOp Tcgen05MMASparseBlockScaleOpGenericAdaptorBase::getCollectorOp() { auto attr = getCollectorOpAttr(); return attr.getValue(); } } // namespace detail Tcgen05MMASparseBlockScaleOpAdaptor::Tcgen05MMASparseBlockScaleOpAdaptor(Tcgen05MMASparseBlockScaleOp op) : Tcgen05MMASparseBlockScaleOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05MMASparseBlockScaleOpAdaptor::verify(::mlir::Location loc) { auto tblgen_blockScale = getProperties().blockScale; (void)tblgen_blockScale; auto tblgen_collectorOp = getProperties().collectorOp; (void)tblgen_collectorOp; auto tblgen_ctaGroup = getProperties().ctaGroup; (void)tblgen_ctaGroup; if (!tblgen_ctaGroup) return emitError(loc, "'nvvm.tcgen05.mma.sp.block_scale' op requires attribute 'ctaGroup'"); auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'nvvm.tcgen05.mma.sp.block_scale' op requires attribute 'kind'"); if (tblgen_kind && !(((::llvm::isa<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind))) && (((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::MXF8F6F4)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::MXF4)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::MXF4NVF4))))) return emitError(loc, "'nvvm.tcgen05.mma.sp.block_scale' op attribute 'kind' failed to satisfy constraint: tcgen05 MMA Supported Types whose value is one of {mxf8f6f4, mxf4, mxf4nvf4}"); if (tblgen_ctaGroup && !((::llvm::isa<::mlir::NVVM::CTAGroupKindAttr>(tblgen_ctaGroup)))) return emitError(loc, "'nvvm.tcgen05.mma.sp.block_scale' op attribute 'ctaGroup' failed to satisfy constraint: NVVM CTA group kind"); if (tblgen_blockScale && !((::llvm::isa<::mlir::NVVM::Tcgen05MMABlockScaleAttr>(tblgen_blockScale)))) return emitError(loc, "'nvvm.tcgen05.mma.sp.block_scale' op attribute 'blockScale' failed to satisfy constraint: tcgen05.mma block scale attribute"); if (tblgen_collectorOp && !((::llvm::isa<::mlir::NVVM::Tcgen05MMACollectorOpAttr>(tblgen_collectorOp)))) return emitError(loc, "'nvvm.tcgen05.mma.sp.block_scale' op attribute 'collectorOp' failed to satisfy constraint: tcgen05.mma Collector Buffer Operation"); return ::mlir::success(); } ::llvm::LogicalResult Tcgen05MMASparseBlockScaleOp::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.blockScale; auto attr = dict.get("blockScale"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `blockScale` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.collectorOp; auto attr = dict.get("collectorOp"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `collectorOp` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.ctaGroup; auto attr = dict.get("ctaGroup"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ctaGroup` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Tcgen05MMASparseBlockScaleOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.blockScale; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("blockScale", propStorage)); } { const auto &propStorage = prop.collectorOp; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("collectorOp", propStorage)); } { const auto &propStorage = prop.ctaGroup; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ctaGroup", propStorage)); } { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Tcgen05MMASparseBlockScaleOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.blockScale.getAsOpaquePointer()), llvm::hash_value(prop.collectorOp.getAsOpaquePointer()), llvm::hash_value(prop.ctaGroup.getAsOpaquePointer()), llvm::hash_value(prop.kind.getAsOpaquePointer())); } std::optional Tcgen05MMASparseBlockScaleOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "blockScale") return prop.blockScale; if (name == "collectorOp") return prop.collectorOp; if (name == "ctaGroup") return prop.ctaGroup; if (name == "kind") return prop.kind; return std::nullopt; } void Tcgen05MMASparseBlockScaleOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "blockScale") { prop.blockScale = ::llvm::dyn_cast_or_null>(value); return; } if (name == "collectorOp") { prop.collectorOp = ::llvm::dyn_cast_or_null>(value); return; } if (name == "ctaGroup") { prop.ctaGroup = ::llvm::dyn_cast_or_null>(value); return; } if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } } void Tcgen05MMASparseBlockScaleOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.blockScale) attrs.append("blockScale", prop.blockScale); if (prop.collectorOp) attrs.append("collectorOp", prop.collectorOp); if (prop.ctaGroup) attrs.append("ctaGroup", prop.ctaGroup); if (prop.kind) attrs.append("kind", prop.kind); } ::llvm::LogicalResult Tcgen05MMASparseBlockScaleOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getBlockScaleAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps59(attr, "blockScale", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getCollectorOpAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps60(attr, "collectorOp", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getCtaGroupAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(attr, "ctaGroup", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps58(attr, "kind", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05MMASparseBlockScaleOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.blockScale))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.collectorOp))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.ctaGroup))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.kind))) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05MMASparseBlockScaleOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.blockScale); writer.writeOptionalAttribute(prop.collectorOp); writer.writeAttribute(prop.ctaGroup); writer.writeAttribute(prop.kind); } ::mlir::NVVM::Tcgen05MMAKind Tcgen05MMASparseBlockScaleOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::mlir::NVVM::CTAGroupKind Tcgen05MMASparseBlockScaleOp::getCtaGroup() { auto attr = getCtaGroupAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMABlockScale Tcgen05MMASparseBlockScaleOp::getBlockScale() { auto attr = getBlockScaleAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMACollectorOp Tcgen05MMASparseBlockScaleOp::getCollectorOp() { auto attr = getCollectorOpAttr(); return attr.getValue(); } void Tcgen05MMASparseBlockScaleOp::setKind(::mlir::NVVM::Tcgen05MMAKind attrValue) { getProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMASparseBlockScaleOp::setCtaGroup(::mlir::NVVM::CTAGroupKind attrValue) { getProperties().ctaGroup = ::mlir::NVVM::CTAGroupKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMASparseBlockScaleOp::setBlockScale(::mlir::NVVM::Tcgen05MMABlockScale attrValue) { getProperties().blockScale = ::mlir::NVVM::Tcgen05MMABlockScaleAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMASparseBlockScaleOp::setCollectorOp(::mlir::NVVM::Tcgen05MMACollectorOp attrValue) { getProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMASparseBlockScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScaleAttr blockScale, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, ::mlir::Value scaleA, ::mlir::Value scaleB) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); odsState.addOperands(sparseMetadata); odsState.addOperands(scaleA); odsState.addOperands(scaleB); odsState.getOrAddProperties().kind = kind; odsState.getOrAddProperties().ctaGroup = ctaGroup; if (blockScale) { odsState.getOrAddProperties().blockScale = blockScale; } if (collectorOp) { odsState.getOrAddProperties().collectorOp = collectorOp; } } Tcgen05MMASparseBlockScaleOp Tcgen05MMASparseBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScaleAttr blockScale, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, ::mlir::Value scaleA, ::mlir::Value scaleB) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind), std::forward(ctaGroup), std::forward(blockScale), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(scaleA), std::forward(scaleB)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMASparseBlockScaleOp Tcgen05MMASparseBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScaleAttr blockScale, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, ::mlir::Value scaleA, ::mlir::Value scaleB) { return create(builder, builder.getLoc(), std::forward(kind), std::forward(ctaGroup), std::forward(blockScale), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(scaleA), std::forward(scaleB)); } void Tcgen05MMASparseBlockScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScaleAttr blockScale, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, ::mlir::Value scaleA, ::mlir::Value scaleB) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); odsState.addOperands(sparseMetadata); odsState.addOperands(scaleA); odsState.addOperands(scaleB); odsState.getOrAddProperties().kind = kind; odsState.getOrAddProperties().ctaGroup = ctaGroup; if (blockScale) { odsState.getOrAddProperties().blockScale = blockScale; } if (collectorOp) { odsState.getOrAddProperties().collectorOp = collectorOp; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05MMASparseBlockScaleOp Tcgen05MMASparseBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScaleAttr blockScale, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, ::mlir::Value scaleA, ::mlir::Value scaleB) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind), std::forward(ctaGroup), std::forward(blockScale), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(scaleA), std::forward(scaleB)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMASparseBlockScaleOp Tcgen05MMASparseBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScaleAttr blockScale, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, ::mlir::Value scaleA, ::mlir::Value scaleB) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind), std::forward(ctaGroup), std::forward(blockScale), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(scaleA), std::forward(scaleB)); } void Tcgen05MMASparseBlockScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScale blockScale, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, ::mlir::Value scaleA, ::mlir::Value scaleB) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); odsState.addOperands(sparseMetadata); odsState.addOperands(scaleA); odsState.addOperands(scaleB); odsState.getOrAddProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(odsBuilder.getContext(), kind); odsState.getOrAddProperties().ctaGroup = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), ctaGroup); odsState.getOrAddProperties().blockScale = ::mlir::NVVM::Tcgen05MMABlockScaleAttr::get(odsBuilder.getContext(), blockScale); odsState.getOrAddProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), collectorOp); } Tcgen05MMASparseBlockScaleOp Tcgen05MMASparseBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScale blockScale, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, ::mlir::Value scaleA, ::mlir::Value scaleB) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind), std::forward(ctaGroup), std::forward(blockScale), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(scaleA), std::forward(scaleB)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMASparseBlockScaleOp Tcgen05MMASparseBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScale blockScale, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, ::mlir::Value scaleA, ::mlir::Value scaleB) { return create(builder, builder.getLoc(), std::forward(kind), std::forward(ctaGroup), std::forward(blockScale), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(scaleA), std::forward(scaleB)); } void Tcgen05MMASparseBlockScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScale blockScale, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, ::mlir::Value scaleA, ::mlir::Value scaleB) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); odsState.addOperands(sparseMetadata); odsState.addOperands(scaleA); odsState.addOperands(scaleB); odsState.getOrAddProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(odsBuilder.getContext(), kind); odsState.getOrAddProperties().ctaGroup = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), ctaGroup); odsState.getOrAddProperties().blockScale = ::mlir::NVVM::Tcgen05MMABlockScaleAttr::get(odsBuilder.getContext(), blockScale); odsState.getOrAddProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), collectorOp); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05MMASparseBlockScaleOp Tcgen05MMASparseBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScale blockScale, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, ::mlir::Value scaleA, ::mlir::Value scaleB) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind), std::forward(ctaGroup), std::forward(blockScale), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(scaleA), std::forward(scaleB)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMASparseBlockScaleOp Tcgen05MMASparseBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMABlockScale blockScale, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, ::mlir::Value scaleA, ::mlir::Value scaleB) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind), std::forward(ctaGroup), std::forward(blockScale), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(scaleA), std::forward(scaleB)); } void Tcgen05MMASparseBlockScaleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 8u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05MMASparseBlockScaleOp Tcgen05MMASparseBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMASparseBlockScaleOp Tcgen05MMASparseBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05MMASparseBlockScaleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 8u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05MMASparseBlockScaleOp Tcgen05MMASparseBlockScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMASparseBlockScaleOp Tcgen05MMASparseBlockScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Tcgen05MMASparseBlockScaleOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.blockScale) properties.blockScale = ::mlir::NVVM::Tcgen05MMABlockScaleAttr::get(odsBuilder.getContext(), Tcgen05MMABlockScale::DEFAULT); if (!properties.collectorOp) properties.collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), Tcgen05MMACollectorOp::DISCARD); } ::llvm::LogicalResult Tcgen05MMASparseBlockScaleOp::verifyInvariantsImpl() { auto tblgen_blockScale = getProperties().blockScale; (void)tblgen_blockScale; auto tblgen_collectorOp = getProperties().collectorOp; (void)tblgen_collectorOp; auto tblgen_ctaGroup = getProperties().ctaGroup; (void)tblgen_ctaGroup; if (!tblgen_ctaGroup) return emitOpError("requires attribute 'ctaGroup'"); auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps58(*this, tblgen_kind, "kind"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(*this, tblgen_ctaGroup, "ctaGroup"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps59(*this, tblgen_blockScale, "blockScale"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps60(*this, tblgen_collectorOp, "collectorOp"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps43(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps23(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup5 = getODSOperands(5); for (auto v : valueGroup5) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup6 = getODSOperands(6); for (auto v : valueGroup6) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup7 = getODSOperands(7); for (auto v : valueGroup7) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05MMASparseBlockScaleOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult Tcgen05MMASparseBlockScaleOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand matrixDRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixDOperands(&matrixDRawOperand, 1); ::llvm::SMLoc matrixDOperandsLoc; (void)matrixDOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand matrixARawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixAOperands(&matrixARawOperand, 1); ::llvm::SMLoc matrixAOperandsLoc; (void)matrixAOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand matrixBRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixBOperands(&matrixBRawOperand, 1); ::llvm::SMLoc matrixBOperandsLoc; (void)matrixBOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand idescRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> idescOperands(&idescRawOperand, 1); ::llvm::SMLoc idescOperandsLoc; (void)idescOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand enableInputDRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> enableInputDOperands(&enableInputDRawOperand, 1); ::llvm::SMLoc enableInputDOperandsLoc; (void)enableInputDOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand sparseMetadataRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sparseMetadataOperands(&sparseMetadataRawOperand, 1); ::llvm::SMLoc sparseMetadataOperandsLoc; (void)sparseMetadataOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand scaleARawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> scaleAOperands(&scaleARawOperand, 1); ::llvm::SMLoc scaleAOperandsLoc; (void)scaleAOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand scaleBRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> scaleBOperands(&scaleBRawOperand, 1); ::llvm::SMLoc scaleBOperandsLoc; (void)scaleBOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; matrixDOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixDRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); matrixAOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixARawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); matrixBOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixBRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); idescOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(idescRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); enableInputDOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(enableInputDRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); sparseMetadataOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sparseMetadataRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); scaleAOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(scaleARawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); scaleBOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(scaleBRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); if (parser.resolveOperands(::llvm::concat(matrixDOperands, matrixAOperands, matrixBOperands, idescOperands, enableInputDOperands, sparseMetadataOperands, scaleAOperands, scaleBOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05MMASparseBlockScaleOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getMatrixD(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMatrixA(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMatrixB(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getIdesc(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getEnableInputD(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSparseMetadata(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getScaleA(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getScaleB(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getBlockScaleAttr(); if(attr && (attr == ::mlir::NVVM::Tcgen05MMABlockScaleAttr::get(odsBuilder.getContext(), Tcgen05MMABlockScale::DEFAULT))) elidedAttrs.push_back("blockScale"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getCollectorOpAttr(); if(attr && (attr == ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), Tcgen05MMACollectorOp::DISCARD))) elidedAttrs.push_back("collectorOp"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' ' << "("; _odsPrinter << getOperation()->getOperandTypes(); _odsPrinter << ")"; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05MMASparseBlockScaleOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05MMASparseBlockScaleOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05MMASparseOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05MMASparseOpGenericAdaptorBase::Tcgen05MMASparseOpGenericAdaptorBase(Tcgen05MMASparseOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair Tcgen05MMASparseOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::NVVM::Tcgen05MMAKind Tcgen05MMASparseOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::mlir::NVVM::CTAGroupKind Tcgen05MMASparseOpGenericAdaptorBase::getCtaGroup() { auto attr = getCtaGroupAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMACollectorOpAttr Tcgen05MMASparseOpGenericAdaptorBase::getCollectorOpAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::Tcgen05MMACollectorOpAttr>(getProperties().collectorOp); return attr; } ::mlir::NVVM::Tcgen05MMACollectorOp Tcgen05MMASparseOpGenericAdaptorBase::getCollectorOp() { auto attr = getCollectorOpAttr(); return attr.getValue(); } ::mlir::UnitAttr Tcgen05MMASparseOpGenericAdaptorBase::getAShiftAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().aShift); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool Tcgen05MMASparseOpGenericAdaptorBase::getAShift() { auto attr = getAShiftAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail Tcgen05MMASparseOpAdaptor::Tcgen05MMASparseOpAdaptor(Tcgen05MMASparseOp op) : Tcgen05MMASparseOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05MMASparseOpAdaptor::verify(::mlir::Location loc) { auto tblgen_aShift = getProperties().aShift; (void)tblgen_aShift; auto tblgen_collectorOp = getProperties().collectorOp; (void)tblgen_collectorOp; auto tblgen_ctaGroup = getProperties().ctaGroup; (void)tblgen_ctaGroup; if (!tblgen_ctaGroup) return emitError(loc, "'nvvm.tcgen05.mma.sp' op requires attribute 'ctaGroup'"); auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'nvvm.tcgen05.mma.sp' op requires attribute 'kind'"); if (tblgen_kind && !(((::llvm::isa<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind))) && (((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::F16)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::TF32)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::F8F6F4)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::I8))))) return emitError(loc, "'nvvm.tcgen05.mma.sp' op attribute 'kind' failed to satisfy constraint: tcgen05 MMA Supported Types whose value is one of {f16, tf32, f8f6f4, i8}"); if (tblgen_ctaGroup && !((::llvm::isa<::mlir::NVVM::CTAGroupKindAttr>(tblgen_ctaGroup)))) return emitError(loc, "'nvvm.tcgen05.mma.sp' op attribute 'ctaGroup' failed to satisfy constraint: NVVM CTA group kind"); if (tblgen_collectorOp && !((::llvm::isa<::mlir::NVVM::Tcgen05MMACollectorOpAttr>(tblgen_collectorOp)))) return emitError(loc, "'nvvm.tcgen05.mma.sp' op attribute 'collectorOp' failed to satisfy constraint: tcgen05.mma Collector Buffer Operation"); if (tblgen_aShift && !((::llvm::isa<::mlir::UnitAttr>(tblgen_aShift)))) return emitError(loc, "'nvvm.tcgen05.mma.sp' op attribute 'aShift' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } std::pair Tcgen05MMASparseOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange Tcgen05MMASparseOp::getScaleInputDMutable() { 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 Tcgen05MMASparseOp::getDisableOutputLaneMutable() { auto range = getODSOperandIndexAndLength(7); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(7u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult Tcgen05MMASparseOp::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.aShift; auto attr = dict.get("aShift"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `aShift` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.collectorOp; auto attr = dict.get("collectorOp"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `collectorOp` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.ctaGroup; auto attr = dict.get("ctaGroup"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ctaGroup` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } { 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 Tcgen05MMASparseOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.aShift; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("aShift", propStorage)); } { const auto &propStorage = prop.collectorOp; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("collectorOp", propStorage)); } { const auto &propStorage = prop.ctaGroup; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ctaGroup", propStorage)); } { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", 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 Tcgen05MMASparseOp::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.aShift.getAsOpaquePointer()), llvm::hash_value(prop.collectorOp.getAsOpaquePointer()), llvm::hash_value(prop.ctaGroup.getAsOpaquePointer()), llvm::hash_value(prop.kind.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional Tcgen05MMASparseOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "aShift") return prop.aShift; if (name == "collectorOp") return prop.collectorOp; if (name == "ctaGroup") return prop.ctaGroup; if (name == "kind") return prop.kind; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void Tcgen05MMASparseOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "aShift") { prop.aShift = ::llvm::dyn_cast_or_null>(value); return; } if (name == "collectorOp") { prop.collectorOp = ::llvm::dyn_cast_or_null>(value); return; } if (name == "ctaGroup") { prop.ctaGroup = ::llvm::dyn_cast_or_null>(value); return; } if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void Tcgen05MMASparseOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.aShift) attrs.append("aShift", prop.aShift); if (prop.collectorOp) attrs.append("collectorOp", prop.collectorOp); if (prop.ctaGroup) attrs.append("ctaGroup", prop.ctaGroup); if (prop.kind) attrs.append("kind", prop.kind); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult Tcgen05MMASparseOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAShiftAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "aShift", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getCollectorOpAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps60(attr, "collectorOp", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getCtaGroupAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(attr, "ctaGroup", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps61(attr, "kind", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05MMASparseOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.aShift))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.collectorOp))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.ctaGroup))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.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(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void Tcgen05MMASparseOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.aShift); writer.writeOptionalAttribute(prop.collectorOp); writer.writeAttribute(prop.ctaGroup); writer.writeAttribute(prop.kind); 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)); ; } } ::mlir::NVVM::Tcgen05MMAKind Tcgen05MMASparseOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::mlir::NVVM::CTAGroupKind Tcgen05MMASparseOp::getCtaGroup() { auto attr = getCtaGroupAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMACollectorOp Tcgen05MMASparseOp::getCollectorOp() { auto attr = getCollectorOpAttr(); return attr.getValue(); } bool Tcgen05MMASparseOp::getAShift() { auto attr = getAShiftAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void Tcgen05MMASparseOp::setKind(::mlir::NVVM::Tcgen05MMAKind attrValue) { getProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMASparseOp::setCtaGroup(::mlir::NVVM::CTAGroupKind attrValue) { getProperties().ctaGroup = ::mlir::NVVM::CTAGroupKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMASparseOp::setCollectorOp(::mlir::NVVM::Tcgen05MMACollectorOp attrValue) { getProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMASparseOp::setAShift(bool attrValue) { auto &odsProp = getProperties().aShift; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void Tcgen05MMASparseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, /*optional*/::mlir::UnitAttr aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); odsState.addOperands(sparseMetadata); if (scaleInputD) odsState.addOperands(scaleInputD); if (disableOutputLane) odsState.addOperands(disableOutputLane); ::llvm::copy(::llvm::ArrayRef({1, 1, 1, 1, 1, 1, (scaleInputD ? 1 : 0), (disableOutputLane ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().kind = kind; odsState.getOrAddProperties().ctaGroup = ctaGroup; if (collectorOp) { odsState.getOrAddProperties().collectorOp = collectorOp; } if (aShift) { odsState.getOrAddProperties().aShift = aShift; } } Tcgen05MMASparseOp Tcgen05MMASparseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, /*optional*/::mlir::UnitAttr aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind), std::forward(ctaGroup), std::forward(collectorOp), std::forward(aShift), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(scaleInputD), std::forward(disableOutputLane)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMASparseOp Tcgen05MMASparseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, /*optional*/::mlir::UnitAttr aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { return create(builder, builder.getLoc(), std::forward(kind), std::forward(ctaGroup), std::forward(collectorOp), std::forward(aShift), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(scaleInputD), std::forward(disableOutputLane)); } void Tcgen05MMASparseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, /*optional*/::mlir::UnitAttr aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); odsState.addOperands(sparseMetadata); if (scaleInputD) odsState.addOperands(scaleInputD); if (disableOutputLane) odsState.addOperands(disableOutputLane); ::llvm::copy(::llvm::ArrayRef({1, 1, 1, 1, 1, 1, (scaleInputD ? 1 : 0), (disableOutputLane ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().kind = kind; odsState.getOrAddProperties().ctaGroup = ctaGroup; if (collectorOp) { odsState.getOrAddProperties().collectorOp = collectorOp; } if (aShift) { odsState.getOrAddProperties().aShift = aShift; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05MMASparseOp Tcgen05MMASparseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, /*optional*/::mlir::UnitAttr aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind), std::forward(ctaGroup), std::forward(collectorOp), std::forward(aShift), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(scaleInputD), std::forward(disableOutputLane)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMASparseOp Tcgen05MMASparseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::CTAGroupKindAttr ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, /*optional*/::mlir::UnitAttr aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind), std::forward(ctaGroup), std::forward(collectorOp), std::forward(aShift), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(scaleInputD), std::forward(disableOutputLane)); } void Tcgen05MMASparseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, /*optional*/bool aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); odsState.addOperands(sparseMetadata); if (scaleInputD) odsState.addOperands(scaleInputD); if (disableOutputLane) odsState.addOperands(disableOutputLane); ::llvm::copy(::llvm::ArrayRef({1, 1, 1, 1, 1, 1, (scaleInputD ? 1 : 0), (disableOutputLane ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(odsBuilder.getContext(), kind); odsState.getOrAddProperties().ctaGroup = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), ctaGroup); odsState.getOrAddProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), collectorOp); if (aShift) { odsState.getOrAddProperties().aShift = ((aShift) ? odsBuilder.getUnitAttr() : nullptr); } } Tcgen05MMASparseOp Tcgen05MMASparseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, /*optional*/bool aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind), std::forward(ctaGroup), std::forward(collectorOp), std::forward(aShift), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(scaleInputD), std::forward(disableOutputLane)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMASparseOp Tcgen05MMASparseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, /*optional*/bool aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { return create(builder, builder.getLoc(), std::forward(kind), std::forward(ctaGroup), std::forward(collectorOp), std::forward(aShift), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(scaleInputD), std::forward(disableOutputLane)); } void Tcgen05MMASparseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, /*optional*/bool aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); odsState.addOperands(sparseMetadata); if (scaleInputD) odsState.addOperands(scaleInputD); if (disableOutputLane) odsState.addOperands(disableOutputLane); ::llvm::copy(::llvm::ArrayRef({1, 1, 1, 1, 1, 1, (scaleInputD ? 1 : 0), (disableOutputLane ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(odsBuilder.getContext(), kind); odsState.getOrAddProperties().ctaGroup = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), ctaGroup); odsState.getOrAddProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), collectorOp); if (aShift) { odsState.getOrAddProperties().aShift = ((aShift) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05MMASparseOp Tcgen05MMASparseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, /*optional*/bool aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind), std::forward(ctaGroup), std::forward(collectorOp), std::forward(aShift), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(scaleInputD), std::forward(disableOutputLane)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMASparseOp Tcgen05MMASparseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::CTAGroupKind ctaGroup, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, /*optional*/bool aShift, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value scaleInputD, /*optional*/::mlir::Value disableOutputLane) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind), std::forward(ctaGroup), std::forward(collectorOp), std::forward(aShift), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(scaleInputD), std::forward(disableOutputLane)); } void Tcgen05MMASparseOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 6u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05MMASparseOp Tcgen05MMASparseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMASparseOp Tcgen05MMASparseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05MMASparseOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 6u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05MMASparseOp Tcgen05MMASparseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMASparseOp Tcgen05MMASparseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Tcgen05MMASparseOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.collectorOp) properties.collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), Tcgen05MMACollectorOp::DISCARD); } ::llvm::LogicalResult Tcgen05MMASparseOp::verifyInvariantsImpl() { auto tblgen_aShift = getProperties().aShift; (void)tblgen_aShift; auto tblgen_collectorOp = getProperties().collectorOp; (void)tblgen_collectorOp; auto tblgen_ctaGroup = getProperties().ctaGroup; (void)tblgen_ctaGroup; if (!tblgen_ctaGroup) return emitOpError("requires attribute 'ctaGroup'"); auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps61(*this, tblgen_kind, "kind"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(*this, tblgen_ctaGroup, "ctaGroup"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps60(*this, tblgen_collectorOp, "collectorOp"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_aShift, "aShift"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps43(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps23(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup5 = getODSOperands(5); for (auto v : valueGroup5) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*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_NVVMOps4(*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_NVVMOps44(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05MMASparseOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult Tcgen05MMASparseOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand matrixDRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixDOperands(&matrixDRawOperand, 1); ::llvm::SMLoc matrixDOperandsLoc; (void)matrixDOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand matrixARawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixAOperands(&matrixARawOperand, 1); ::llvm::SMLoc matrixAOperandsLoc; (void)matrixAOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand matrixBRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixBOperands(&matrixBRawOperand, 1); ::llvm::SMLoc matrixBOperandsLoc; (void)matrixBOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand idescRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> idescOperands(&idescRawOperand, 1); ::llvm::SMLoc idescOperandsLoc; (void)idescOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand enableInputDRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> enableInputDOperands(&enableInputDRawOperand, 1); ::llvm::SMLoc enableInputDOperandsLoc; (void)enableInputDOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand sparseMetadataRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sparseMetadataOperands(&sparseMetadataRawOperand, 1); ::llvm::SMLoc sparseMetadataOperandsLoc; (void)sparseMetadataOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> scaleInputDOperands; ::llvm::SMLoc scaleInputDOperandsLoc; (void)scaleInputDOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> disableOutputLaneOperands; ::llvm::SMLoc disableOutputLaneOperandsLoc; (void)disableOutputLaneOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; matrixDOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixDRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); matrixAOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixARawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); matrixBOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixBRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); idescOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(idescRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); enableInputDOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(enableInputDRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); sparseMetadataOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sparseMetadataRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("scale"))) { if (parser.parseEqual()) return ::mlir::failure(); { scaleInputDOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); scaleInputDOperands.push_back(operand); } } } if (::mlir::succeeded(parser.parseOptionalKeyword("mask"))) { if (parser.parseEqual()) return ::mlir::failure(); { disableOutputLaneOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); disableOutputLaneOperands.push_back(operand); } } } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); ::llvm::copy(::llvm::ArrayRef({1, 1, 1, 1, 1, 1, static_cast(scaleInputDOperands.size()), static_cast(disableOutputLaneOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); if (parser.resolveOperands(::llvm::concat(matrixDOperands, matrixAOperands, matrixBOperands, idescOperands, enableInputDOperands, sparseMetadataOperands, scaleInputDOperands, disableOutputLaneOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05MMASparseOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getMatrixD(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMatrixA(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMatrixB(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getIdesc(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getEnableInputD(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSparseMetadata(); if (getScaleInputD()) { _odsPrinter << ' ' << "scale"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getScaleInputD()) _odsPrinter << value; } if (getDisableOutputLane()) { _odsPrinter << ' ' << "mask"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; if (::mlir::Value value = getDisableOutputLane()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getCollectorOpAttr(); if(attr && (attr == ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), Tcgen05MMACollectorOp::DISCARD))) elidedAttrs.push_back("collectorOp"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getAShiftAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("aShift"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' ' << "("; _odsPrinter << getOperation()->getOperandTypes(); _odsPrinter << ")"; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05MMASparseOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05MMASparseOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05MMAWsOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05MMAWsOpGenericAdaptorBase::Tcgen05MMAWsOpGenericAdaptorBase(Tcgen05MMAWsOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair Tcgen05MMAWsOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, false, false, false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 5) / 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::NVVM::Tcgen05MMAKind Tcgen05MMAWsOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr Tcgen05MMAWsOpGenericAdaptorBase::getCollectorBBufferAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::Tcgen05MMACollectorBBufferAttr>(getProperties().collectorBBuffer); return attr; } ::mlir::NVVM::Tcgen05MMACollectorBBuffer Tcgen05MMAWsOpGenericAdaptorBase::getCollectorBBuffer() { auto attr = getCollectorBBufferAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMACollectorOpAttr Tcgen05MMAWsOpGenericAdaptorBase::getCollectorOpAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::Tcgen05MMACollectorOpAttr>(getProperties().collectorOp); return attr; } ::mlir::NVVM::Tcgen05MMACollectorOp Tcgen05MMAWsOpGenericAdaptorBase::getCollectorOp() { auto attr = getCollectorOpAttr(); return attr.getValue(); } } // namespace detail Tcgen05MMAWsOpAdaptor::Tcgen05MMAWsOpAdaptor(Tcgen05MMAWsOp op) : Tcgen05MMAWsOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05MMAWsOpAdaptor::verify(::mlir::Location loc) { auto tblgen_collectorBBuffer = getProperties().collectorBBuffer; (void)tblgen_collectorBBuffer; auto tblgen_collectorOp = getProperties().collectorOp; (void)tblgen_collectorOp; auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'nvvm.tcgen05.mma.ws' op requires attribute 'kind'"); if (tblgen_kind && !(((::llvm::isa<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind))) && (((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::F16)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::TF32)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::F8F6F4)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::I8))))) return emitError(loc, "'nvvm.tcgen05.mma.ws' op attribute 'kind' failed to satisfy constraint: tcgen05 MMA Supported Types whose value is one of {f16, tf32, f8f6f4, i8}"); if (tblgen_collectorBBuffer && !((::llvm::isa<::mlir::NVVM::Tcgen05MMACollectorBBufferAttr>(tblgen_collectorBBuffer)))) return emitError(loc, "'nvvm.tcgen05.mma.ws' op attribute 'collectorBBuffer' failed to satisfy constraint: tcgen05 MMA Collector Buffer B Attribute"); if (tblgen_collectorOp && !((::llvm::isa<::mlir::NVVM::Tcgen05MMACollectorOpAttr>(tblgen_collectorOp)))) return emitError(loc, "'nvvm.tcgen05.mma.ws' op attribute 'collectorOp' failed to satisfy constraint: tcgen05.mma Collector Buffer Operation"); return ::mlir::success(); } std::pair Tcgen05MMAWsOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, false, false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 5) / 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 Tcgen05MMAWsOp::getZeroColMaskMutable() { auto range = getODSOperandIndexAndLength(5); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult Tcgen05MMAWsOp::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.collectorBBuffer; auto attr = dict.get("collectorBBuffer"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `collectorBBuffer` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.collectorOp; auto attr = dict.get("collectorOp"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `collectorOp` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Tcgen05MMAWsOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.collectorBBuffer; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("collectorBBuffer", propStorage)); } { const auto &propStorage = prop.collectorOp; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("collectorOp", propStorage)); } { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Tcgen05MMAWsOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.collectorBBuffer.getAsOpaquePointer()), llvm::hash_value(prop.collectorOp.getAsOpaquePointer()), llvm::hash_value(prop.kind.getAsOpaquePointer())); } std::optional Tcgen05MMAWsOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "collectorBBuffer") return prop.collectorBBuffer; if (name == "collectorOp") return prop.collectorOp; if (name == "kind") return prop.kind; return std::nullopt; } void Tcgen05MMAWsOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "collectorBBuffer") { prop.collectorBBuffer = ::llvm::dyn_cast_or_null>(value); return; } if (name == "collectorOp") { prop.collectorOp = ::llvm::dyn_cast_or_null>(value); return; } if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } } void Tcgen05MMAWsOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.collectorBBuffer) attrs.append("collectorBBuffer", prop.collectorBBuffer); if (prop.collectorOp) attrs.append("collectorOp", prop.collectorOp); if (prop.kind) attrs.append("kind", prop.kind); } ::llvm::LogicalResult Tcgen05MMAWsOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getCollectorBBufferAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps62(attr, "collectorBBuffer", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getCollectorOpAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps60(attr, "collectorOp", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps61(attr, "kind", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05MMAWsOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.collectorBBuffer))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.collectorOp))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.kind))) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05MMAWsOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.collectorBBuffer); writer.writeOptionalAttribute(prop.collectorOp); writer.writeAttribute(prop.kind); } ::mlir::NVVM::Tcgen05MMAKind Tcgen05MMAWsOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMACollectorBBuffer Tcgen05MMAWsOp::getCollectorBBuffer() { auto attr = getCollectorBBufferAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMACollectorOp Tcgen05MMAWsOp::getCollectorOp() { auto attr = getCollectorOpAttr(); return attr.getValue(); } void Tcgen05MMAWsOp::setKind(::mlir::NVVM::Tcgen05MMAKind attrValue) { getProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMAWsOp::setCollectorBBuffer(::mlir::NVVM::Tcgen05MMACollectorBBuffer attrValue) { getProperties().collectorBBuffer = ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMAWsOp::setCollectorOp(::mlir::NVVM::Tcgen05MMACollectorOp attrValue) { getProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMAWsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value zeroColMask) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); if (zeroColMask) odsState.addOperands(zeroColMask); odsState.getOrAddProperties().kind = kind; if (collectorBBuffer) { odsState.getOrAddProperties().collectorBBuffer = collectorBBuffer; } if (collectorOp) { odsState.getOrAddProperties().collectorOp = collectorOp; } } Tcgen05MMAWsOp Tcgen05MMAWsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value zeroColMask) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind), std::forward(collectorBBuffer), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(zeroColMask)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAWsOp Tcgen05MMAWsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value zeroColMask) { return create(builder, builder.getLoc(), std::forward(kind), std::forward(collectorBBuffer), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(zeroColMask)); } void Tcgen05MMAWsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value zeroColMask) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); if (zeroColMask) odsState.addOperands(zeroColMask); odsState.getOrAddProperties().kind = kind; if (collectorBBuffer) { odsState.getOrAddProperties().collectorBBuffer = collectorBBuffer; } if (collectorOp) { odsState.getOrAddProperties().collectorOp = collectorOp; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05MMAWsOp Tcgen05MMAWsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value zeroColMask) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind), std::forward(collectorBBuffer), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(zeroColMask)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAWsOp Tcgen05MMAWsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value zeroColMask) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind), std::forward(collectorBBuffer), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(zeroColMask)); } void Tcgen05MMAWsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::Tcgen05MMACollectorBBuffer collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value zeroColMask) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); if (zeroColMask) odsState.addOperands(zeroColMask); odsState.getOrAddProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(odsBuilder.getContext(), kind); odsState.getOrAddProperties().collectorBBuffer = ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr::get(odsBuilder.getContext(), collectorBBuffer); odsState.getOrAddProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), collectorOp); } Tcgen05MMAWsOp Tcgen05MMAWsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::Tcgen05MMACollectorBBuffer collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value zeroColMask) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind), std::forward(collectorBBuffer), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(zeroColMask)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAWsOp Tcgen05MMAWsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::Tcgen05MMACollectorBBuffer collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value zeroColMask) { return create(builder, builder.getLoc(), std::forward(kind), std::forward(collectorBBuffer), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(zeroColMask)); } void Tcgen05MMAWsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::Tcgen05MMACollectorBBuffer collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value zeroColMask) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); if (zeroColMask) odsState.addOperands(zeroColMask); odsState.getOrAddProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(odsBuilder.getContext(), kind); odsState.getOrAddProperties().collectorBBuffer = ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr::get(odsBuilder.getContext(), collectorBBuffer); odsState.getOrAddProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), collectorOp); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05MMAWsOp Tcgen05MMAWsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::Tcgen05MMACollectorBBuffer collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value zeroColMask) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind), std::forward(collectorBBuffer), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(zeroColMask)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAWsOp Tcgen05MMAWsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::Tcgen05MMACollectorBBuffer collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, /*optional*/::mlir::Value zeroColMask) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind), std::forward(collectorBBuffer), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(zeroColMask)); } void Tcgen05MMAWsOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 5u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05MMAWsOp Tcgen05MMAWsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAWsOp Tcgen05MMAWsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05MMAWsOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 5u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05MMAWsOp Tcgen05MMAWsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAWsOp Tcgen05MMAWsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Tcgen05MMAWsOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.collectorBBuffer) properties.collectorBBuffer = ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr::get(odsBuilder.getContext(), Tcgen05MMACollectorBBuffer::B0); if (!properties.collectorOp) properties.collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), Tcgen05MMACollectorOp::DISCARD); } ::llvm::LogicalResult Tcgen05MMAWsOp::verifyInvariantsImpl() { auto tblgen_collectorBBuffer = getProperties().collectorBBuffer; (void)tblgen_collectorBBuffer; auto tblgen_collectorOp = getProperties().collectorOp; (void)tblgen_collectorOp; auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps61(*this, tblgen_kind, "kind"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps62(*this, tblgen_collectorBBuffer, "collectorBBuffer"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps60(*this, tblgen_collectorOp, "collectorOp"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps43(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps23(*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_NVVMOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05MMAWsOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult Tcgen05MMAWsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand matrixDRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixDOperands(&matrixDRawOperand, 1); ::llvm::SMLoc matrixDOperandsLoc; (void)matrixDOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand matrixARawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixAOperands(&matrixARawOperand, 1); ::llvm::SMLoc matrixAOperandsLoc; (void)matrixAOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand matrixBRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixBOperands(&matrixBRawOperand, 1); ::llvm::SMLoc matrixBOperandsLoc; (void)matrixBOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand idescRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> idescOperands(&idescRawOperand, 1); ::llvm::SMLoc idescOperandsLoc; (void)idescOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand enableInputDRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> enableInputDOperands(&enableInputDRawOperand, 1); ::llvm::SMLoc enableInputDOperandsLoc; (void)enableInputDOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> zeroColMaskOperands; ::llvm::SMLoc zeroColMaskOperandsLoc; (void)zeroColMaskOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; matrixDOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixDRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); matrixAOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixARawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); matrixBOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixBRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); idescOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(idescRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); enableInputDOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(enableInputDRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { zeroColMaskOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); zeroColMaskOperands.push_back(operand); } } } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); if (parser.resolveOperands(::llvm::concat(matrixDOperands, matrixAOperands, matrixBOperands, idescOperands, enableInputDOperands, zeroColMaskOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05MMAWsOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getMatrixD(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMatrixA(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMatrixB(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getIdesc(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getEnableInputD(); if (getZeroColMask()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getZeroColMask()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getCollectorBBufferAttr(); if(attr && (attr == ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr::get(odsBuilder.getContext(), Tcgen05MMACollectorBBuffer::B0))) elidedAttrs.push_back("collectorBBuffer"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getCollectorOpAttr(); if(attr && (attr == ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), Tcgen05MMACollectorOp::DISCARD))) elidedAttrs.push_back("collectorOp"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' ' << "("; _odsPrinter << getOperation()->getOperandTypes(); _odsPrinter << ")"; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05MMAWsOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05MMAWsOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05MMAWsSparseOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05MMAWsSparseOpGenericAdaptorBase::Tcgen05MMAWsSparseOpGenericAdaptorBase(Tcgen05MMAWsSparseOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair Tcgen05MMAWsSparseOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, false, false, false, false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 6) / 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::NVVM::Tcgen05MMAKind Tcgen05MMAWsSparseOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr Tcgen05MMAWsSparseOpGenericAdaptorBase::getCollectorBBufferAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::Tcgen05MMACollectorBBufferAttr>(getProperties().collectorBBuffer); return attr; } ::mlir::NVVM::Tcgen05MMACollectorBBuffer Tcgen05MMAWsSparseOpGenericAdaptorBase::getCollectorBBuffer() { auto attr = getCollectorBBufferAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMACollectorOpAttr Tcgen05MMAWsSparseOpGenericAdaptorBase::getCollectorOpAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::Tcgen05MMACollectorOpAttr>(getProperties().collectorOp); return attr; } ::mlir::NVVM::Tcgen05MMACollectorOp Tcgen05MMAWsSparseOpGenericAdaptorBase::getCollectorOp() { auto attr = getCollectorOpAttr(); return attr.getValue(); } } // namespace detail Tcgen05MMAWsSparseOpAdaptor::Tcgen05MMAWsSparseOpAdaptor(Tcgen05MMAWsSparseOp op) : Tcgen05MMAWsSparseOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05MMAWsSparseOpAdaptor::verify(::mlir::Location loc) { auto tblgen_collectorBBuffer = getProperties().collectorBBuffer; (void)tblgen_collectorBBuffer; auto tblgen_collectorOp = getProperties().collectorOp; (void)tblgen_collectorOp; auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'nvvm.tcgen05.mma.ws.sp' op requires attribute 'kind'"); if (tblgen_kind && !(((::llvm::isa<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind))) && (((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::F16)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::TF32)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::F8F6F4)) || ((::llvm::cast<::mlir::NVVM::Tcgen05MMAKindAttr>(tblgen_kind).getValue() == ::mlir::NVVM::Tcgen05MMAKind::I8))))) return emitError(loc, "'nvvm.tcgen05.mma.ws.sp' op attribute 'kind' failed to satisfy constraint: tcgen05 MMA Supported Types whose value is one of {f16, tf32, f8f6f4, i8}"); if (tblgen_collectorBBuffer && !((::llvm::isa<::mlir::NVVM::Tcgen05MMACollectorBBufferAttr>(tblgen_collectorBBuffer)))) return emitError(loc, "'nvvm.tcgen05.mma.ws.sp' op attribute 'collectorBBuffer' failed to satisfy constraint: tcgen05 MMA Collector Buffer B Attribute"); if (tblgen_collectorOp && !((::llvm::isa<::mlir::NVVM::Tcgen05MMACollectorOpAttr>(tblgen_collectorOp)))) return emitError(loc, "'nvvm.tcgen05.mma.ws.sp' op attribute 'collectorOp' failed to satisfy constraint: tcgen05.mma Collector Buffer Operation"); return ::mlir::success(); } std::pair Tcgen05MMAWsSparseOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, false, false, false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 6) / 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 Tcgen05MMAWsSparseOp::getZeroColMaskMutable() { auto range = getODSOperandIndexAndLength(6); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult Tcgen05MMAWsSparseOp::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.collectorBBuffer; auto attr = dict.get("collectorBBuffer"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `collectorBBuffer` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.collectorOp; auto attr = dict.get("collectorOp"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `collectorOp` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Tcgen05MMAWsSparseOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.collectorBBuffer; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("collectorBBuffer", propStorage)); } { const auto &propStorage = prop.collectorOp; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("collectorOp", propStorage)); } { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Tcgen05MMAWsSparseOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.collectorBBuffer.getAsOpaquePointer()), llvm::hash_value(prop.collectorOp.getAsOpaquePointer()), llvm::hash_value(prop.kind.getAsOpaquePointer())); } std::optional Tcgen05MMAWsSparseOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "collectorBBuffer") return prop.collectorBBuffer; if (name == "collectorOp") return prop.collectorOp; if (name == "kind") return prop.kind; return std::nullopt; } void Tcgen05MMAWsSparseOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "collectorBBuffer") { prop.collectorBBuffer = ::llvm::dyn_cast_or_null>(value); return; } if (name == "collectorOp") { prop.collectorOp = ::llvm::dyn_cast_or_null>(value); return; } if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } } void Tcgen05MMAWsSparseOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.collectorBBuffer) attrs.append("collectorBBuffer", prop.collectorBBuffer); if (prop.collectorOp) attrs.append("collectorOp", prop.collectorOp); if (prop.kind) attrs.append("kind", prop.kind); } ::llvm::LogicalResult Tcgen05MMAWsSparseOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getCollectorBBufferAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps62(attr, "collectorBBuffer", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getCollectorOpAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps60(attr, "collectorOp", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps61(attr, "kind", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05MMAWsSparseOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.collectorBBuffer))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.collectorOp))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.kind))) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05MMAWsSparseOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.collectorBBuffer); writer.writeOptionalAttribute(prop.collectorOp); writer.writeAttribute(prop.kind); } ::mlir::NVVM::Tcgen05MMAKind Tcgen05MMAWsSparseOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMACollectorBBuffer Tcgen05MMAWsSparseOp::getCollectorBBuffer() { auto attr = getCollectorBBufferAttr(); return attr.getValue(); } ::mlir::NVVM::Tcgen05MMACollectorOp Tcgen05MMAWsSparseOp::getCollectorOp() { auto attr = getCollectorOpAttr(); return attr.getValue(); } void Tcgen05MMAWsSparseOp::setKind(::mlir::NVVM::Tcgen05MMAKind attrValue) { getProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMAWsSparseOp::setCollectorBBuffer(::mlir::NVVM::Tcgen05MMACollectorBBuffer attrValue) { getProperties().collectorBBuffer = ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMAWsSparseOp::setCollectorOp(::mlir::NVVM::Tcgen05MMACollectorOp attrValue) { getProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05MMAWsSparseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value zeroColMask) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); odsState.addOperands(sparseMetadata); if (zeroColMask) odsState.addOperands(zeroColMask); odsState.getOrAddProperties().kind = kind; if (collectorBBuffer) { odsState.getOrAddProperties().collectorBBuffer = collectorBBuffer; } if (collectorOp) { odsState.getOrAddProperties().collectorOp = collectorOp; } } Tcgen05MMAWsSparseOp Tcgen05MMAWsSparseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value zeroColMask) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind), std::forward(collectorBBuffer), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(zeroColMask)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAWsSparseOp Tcgen05MMAWsSparseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value zeroColMask) { return create(builder, builder.getLoc(), std::forward(kind), std::forward(collectorBBuffer), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(zeroColMask)); } void Tcgen05MMAWsSparseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value zeroColMask) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); odsState.addOperands(sparseMetadata); if (zeroColMask) odsState.addOperands(zeroColMask); odsState.getOrAddProperties().kind = kind; if (collectorBBuffer) { odsState.getOrAddProperties().collectorBBuffer = collectorBBuffer; } if (collectorOp) { odsState.getOrAddProperties().collectorOp = collectorOp; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05MMAWsSparseOp Tcgen05MMAWsSparseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value zeroColMask) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind), std::forward(collectorBBuffer), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(zeroColMask)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAWsSparseOp Tcgen05MMAWsSparseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKindAttr kind, ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOpAttr collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value zeroColMask) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind), std::forward(collectorBBuffer), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(zeroColMask)); } void Tcgen05MMAWsSparseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::Tcgen05MMACollectorBBuffer collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value zeroColMask) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); odsState.addOperands(sparseMetadata); if (zeroColMask) odsState.addOperands(zeroColMask); odsState.getOrAddProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(odsBuilder.getContext(), kind); odsState.getOrAddProperties().collectorBBuffer = ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr::get(odsBuilder.getContext(), collectorBBuffer); odsState.getOrAddProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), collectorOp); } Tcgen05MMAWsSparseOp Tcgen05MMAWsSparseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::Tcgen05MMACollectorBBuffer collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value zeroColMask) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind), std::forward(collectorBBuffer), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(zeroColMask)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAWsSparseOp Tcgen05MMAWsSparseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::Tcgen05MMACollectorBBuffer collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value zeroColMask) { return create(builder, builder.getLoc(), std::forward(kind), std::forward(collectorBBuffer), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(zeroColMask)); } void Tcgen05MMAWsSparseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::Tcgen05MMACollectorBBuffer collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value zeroColMask) { odsState.addOperands(matrixD); odsState.addOperands(matrixA); odsState.addOperands(matrixB); odsState.addOperands(idesc); odsState.addOperands(enableInputD); odsState.addOperands(sparseMetadata); if (zeroColMask) odsState.addOperands(zeroColMask); odsState.getOrAddProperties().kind = ::mlir::NVVM::Tcgen05MMAKindAttr::get(odsBuilder.getContext(), kind); odsState.getOrAddProperties().collectorBBuffer = ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr::get(odsBuilder.getContext(), collectorBBuffer); odsState.getOrAddProperties().collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), collectorOp); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05MMAWsSparseOp Tcgen05MMAWsSparseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::Tcgen05MMACollectorBBuffer collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value zeroColMask) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind), std::forward(collectorBBuffer), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(zeroColMask)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAWsSparseOp Tcgen05MMAWsSparseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05MMAKind kind, ::mlir::NVVM::Tcgen05MMACollectorBBuffer collectorBBuffer, ::mlir::NVVM::Tcgen05MMACollectorOp collectorOp, ::mlir::Value matrixD, ::mlir::Value matrixA, ::mlir::Value matrixB, ::mlir::Value idesc, ::mlir::Value enableInputD, ::mlir::Value sparseMetadata, /*optional*/::mlir::Value zeroColMask) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind), std::forward(collectorBBuffer), std::forward(collectorOp), std::forward(matrixD), std::forward(matrixA), std::forward(matrixB), std::forward(idesc), std::forward(enableInputD), std::forward(sparseMetadata), std::forward(zeroColMask)); } void Tcgen05MMAWsSparseOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 6u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05MMAWsSparseOp Tcgen05MMAWsSparseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAWsSparseOp Tcgen05MMAWsSparseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05MMAWsSparseOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 6u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05MMAWsSparseOp Tcgen05MMAWsSparseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MMAWsSparseOp Tcgen05MMAWsSparseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Tcgen05MMAWsSparseOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.collectorBBuffer) properties.collectorBBuffer = ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr::get(odsBuilder.getContext(), Tcgen05MMACollectorBBuffer::B0); if (!properties.collectorOp) properties.collectorOp = ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), Tcgen05MMACollectorOp::DISCARD); } ::llvm::LogicalResult Tcgen05MMAWsSparseOp::verifyInvariantsImpl() { auto tblgen_collectorBBuffer = getProperties().collectorBBuffer; (void)tblgen_collectorBBuffer; auto tblgen_collectorOp = getProperties().collectorOp; (void)tblgen_collectorOp; auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps61(*this, tblgen_kind, "kind"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps62(*this, tblgen_collectorBBuffer, "collectorBBuffer"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps60(*this, tblgen_collectorOp, "collectorOp"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps43(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps23(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup5 = getODSOperands(5); for (auto v : valueGroup5) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*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_NVVMOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05MMAWsSparseOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult Tcgen05MMAWsSparseOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand matrixDRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixDOperands(&matrixDRawOperand, 1); ::llvm::SMLoc matrixDOperandsLoc; (void)matrixDOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand matrixARawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixAOperands(&matrixARawOperand, 1); ::llvm::SMLoc matrixAOperandsLoc; (void)matrixAOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand matrixBRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixBOperands(&matrixBRawOperand, 1); ::llvm::SMLoc matrixBOperandsLoc; (void)matrixBOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand idescRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> idescOperands(&idescRawOperand, 1); ::llvm::SMLoc idescOperandsLoc; (void)idescOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand enableInputDRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> enableInputDOperands(&enableInputDRawOperand, 1); ::llvm::SMLoc enableInputDOperandsLoc; (void)enableInputDOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand sparseMetadataRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sparseMetadataOperands(&sparseMetadataRawOperand, 1); ::llvm::SMLoc sparseMetadataOperandsLoc; (void)sparseMetadataOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> zeroColMaskOperands; ::llvm::SMLoc zeroColMaskOperandsLoc; (void)zeroColMaskOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; matrixDOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixDRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); matrixAOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixARawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); matrixBOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(matrixBRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); idescOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(idescRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); enableInputDOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(enableInputDRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); sparseMetadataOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sparseMetadataRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { zeroColMaskOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); zeroColMaskOperands.push_back(operand); } } } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); if (parser.resolveOperands(::llvm::concat(matrixDOperands, matrixAOperands, matrixBOperands, idescOperands, enableInputDOperands, sparseMetadataOperands, zeroColMaskOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05MMAWsSparseOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getMatrixD(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMatrixA(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMatrixB(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getIdesc(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getEnableInputD(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getSparseMetadata(); if (getZeroColMask()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getZeroColMask()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getCollectorBBufferAttr(); if(attr && (attr == ::mlir::NVVM::Tcgen05MMACollectorBBufferAttr::get(odsBuilder.getContext(), Tcgen05MMACollectorBBuffer::B0))) elidedAttrs.push_back("collectorBBuffer"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getCollectorOpAttr(); if(attr && (attr == ::mlir::NVVM::Tcgen05MMACollectorOpAttr::get(odsBuilder.getContext(), Tcgen05MMACollectorOp::DISCARD))) elidedAttrs.push_back("collectorOp"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' ' << "("; _odsPrinter << getOperation()->getOperandTypes(); _odsPrinter << ")"; } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05MMAWsSparseOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05MMAWsSparseOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05MmaSmemDescOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05MmaSmemDescOpGenericAdaptorBase::Tcgen05MmaSmemDescOpGenericAdaptorBase(Tcgen05MmaSmemDescOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail Tcgen05MmaSmemDescOpAdaptor::Tcgen05MmaSmemDescOpAdaptor(Tcgen05MmaSmemDescOp op) : Tcgen05MmaSmemDescOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05MmaSmemDescOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult Tcgen05MmaSmemDescOp::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 Tcgen05MmaSmemDescOp::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 Tcgen05MmaSmemDescOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional Tcgen05MmaSmemDescOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void Tcgen05MmaSmemDescOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void Tcgen05MmaSmemDescOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult Tcgen05MmaSmemDescOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void Tcgen05MmaSmemDescOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value startAddr, ::mlir::Value leadingDimOffset, ::mlir::Value strideDimOffset, ::mlir::Value baseOffset, ::mlir::Value leadingDimMode, ::mlir::Value swizzleMode) { odsState.addOperands(startAddr); odsState.addOperands(leadingDimOffset); odsState.addOperands(strideDimOffset); odsState.addOperands(baseOffset); odsState.addOperands(leadingDimMode); odsState.addOperands(swizzleMode); odsState.addTypes(res); } Tcgen05MmaSmemDescOp Tcgen05MmaSmemDescOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value startAddr, ::mlir::Value leadingDimOffset, ::mlir::Value strideDimOffset, ::mlir::Value baseOffset, ::mlir::Value leadingDimMode, ::mlir::Value swizzleMode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(startAddr), std::forward(leadingDimOffset), std::forward(strideDimOffset), std::forward(baseOffset), std::forward(leadingDimMode), std::forward(swizzleMode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MmaSmemDescOp Tcgen05MmaSmemDescOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value startAddr, ::mlir::Value leadingDimOffset, ::mlir::Value strideDimOffset, ::mlir::Value baseOffset, ::mlir::Value leadingDimMode, ::mlir::Value swizzleMode) { return create(builder, builder.getLoc(), std::forward(res), std::forward(startAddr), std::forward(leadingDimOffset), std::forward(strideDimOffset), std::forward(baseOffset), std::forward(leadingDimMode), std::forward(swizzleMode)); } void Tcgen05MmaSmemDescOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value startAddr, ::mlir::Value leadingDimOffset, ::mlir::Value strideDimOffset, ::mlir::Value baseOffset, ::mlir::Value leadingDimMode, ::mlir::Value swizzleMode) { odsState.addOperands(startAddr); odsState.addOperands(leadingDimOffset); odsState.addOperands(strideDimOffset); odsState.addOperands(baseOffset); odsState.addOperands(leadingDimMode); odsState.addOperands(swizzleMode); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(Tcgen05MmaSmemDescOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } Tcgen05MmaSmemDescOp Tcgen05MmaSmemDescOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value startAddr, ::mlir::Value leadingDimOffset, ::mlir::Value strideDimOffset, ::mlir::Value baseOffset, ::mlir::Value leadingDimMode, ::mlir::Value swizzleMode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(startAddr), std::forward(leadingDimOffset), std::forward(strideDimOffset), std::forward(baseOffset), std::forward(leadingDimMode), std::forward(swizzleMode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MmaSmemDescOp Tcgen05MmaSmemDescOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value startAddr, ::mlir::Value leadingDimOffset, ::mlir::Value strideDimOffset, ::mlir::Value baseOffset, ::mlir::Value leadingDimMode, ::mlir::Value swizzleMode) { return create(builder, builder.getLoc(), std::forward(startAddr), std::forward(leadingDimOffset), std::forward(strideDimOffset), std::forward(baseOffset), std::forward(leadingDimMode), std::forward(swizzleMode)); } void Tcgen05MmaSmemDescOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value startAddr, ::mlir::Value leadingDimOffset, ::mlir::Value strideDimOffset, ::mlir::Value baseOffset, ::mlir::Value leadingDimMode, ::mlir::Value swizzleMode) { odsState.addOperands(startAddr); odsState.addOperands(leadingDimOffset); odsState.addOperands(strideDimOffset); odsState.addOperands(baseOffset); odsState.addOperands(leadingDimMode); odsState.addOperands(swizzleMode); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05MmaSmemDescOp Tcgen05MmaSmemDescOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value startAddr, ::mlir::Value leadingDimOffset, ::mlir::Value strideDimOffset, ::mlir::Value baseOffset, ::mlir::Value leadingDimMode, ::mlir::Value swizzleMode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(startAddr), std::forward(leadingDimOffset), std::forward(strideDimOffset), std::forward(baseOffset), std::forward(leadingDimMode), std::forward(swizzleMode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MmaSmemDescOp Tcgen05MmaSmemDescOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value startAddr, ::mlir::Value leadingDimOffset, ::mlir::Value strideDimOffset, ::mlir::Value baseOffset, ::mlir::Value leadingDimMode, ::mlir::Value swizzleMode) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(startAddr), std::forward(leadingDimOffset), std::forward(strideDimOffset), std::forward(baseOffset), std::forward(leadingDimMode), std::forward(swizzleMode)); } void Tcgen05MmaSmemDescOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 6u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05MmaSmemDescOp Tcgen05MmaSmemDescOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MmaSmemDescOp Tcgen05MmaSmemDescOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05MmaSmemDescOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 6u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(Tcgen05MmaSmemDescOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } Tcgen05MmaSmemDescOp Tcgen05MmaSmemDescOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MmaSmemDescOp Tcgen05MmaSmemDescOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void Tcgen05MmaSmemDescOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 6u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05MmaSmemDescOp Tcgen05MmaSmemDescOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MmaSmemDescOp Tcgen05MmaSmemDescOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Tcgen05MmaSmemDescOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 6u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(Tcgen05MmaSmemDescOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } Tcgen05MmaSmemDescOp Tcgen05MmaSmemDescOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05MmaSmemDescOp Tcgen05MmaSmemDescOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult Tcgen05MmaSmemDescOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps9(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps23(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup5 = getODSOperands(5); for (auto v : valueGroup5) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps9(*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_NVVMOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05MmaSmemDescOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult Tcgen05MmaSmemDescOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(64); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult Tcgen05MmaSmemDescOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (parser.parseLParen()) return ::mlir::failure(); [[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation(); if (parser.parseOperandList(allOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); if (parser.resolveOperands(allOperands, allOperandTypes, allOperandLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05MmaSmemDescOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << "("; _odsPrinter << getOperation()->getOperands(); _odsPrinter << ")"; ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' ' << "("; _odsPrinter << getOperation()->getOperandTypes(); _odsPrinter << ")"; _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05MmaSmemDescOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05RelinquishAllocPermitOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05RelinquishAllocPermitOpGenericAdaptorBase::Tcgen05RelinquishAllocPermitOpGenericAdaptorBase(Tcgen05RelinquishAllocPermitOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::CTAGroupKindAttr Tcgen05RelinquishAllocPermitOpGenericAdaptorBase::getGroupAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::CTAGroupKindAttr>(getProperties().group); return attr; } ::mlir::NVVM::CTAGroupKind Tcgen05RelinquishAllocPermitOpGenericAdaptorBase::getGroup() { auto attr = getGroupAttr(); return attr.getValue(); } } // namespace detail Tcgen05RelinquishAllocPermitOpAdaptor::Tcgen05RelinquishAllocPermitOpAdaptor(Tcgen05RelinquishAllocPermitOp op) : Tcgen05RelinquishAllocPermitOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05RelinquishAllocPermitOpAdaptor::verify(::mlir::Location loc) { auto tblgen_group = getProperties().group; (void)tblgen_group; if (tblgen_group && !((::llvm::isa<::mlir::NVVM::CTAGroupKindAttr>(tblgen_group)))) return emitError(loc, "'nvvm.tcgen05.relinquish_alloc_permit' op attribute 'group' failed to satisfy constraint: NVVM CTA group kind"); return ::mlir::success(); } ::llvm::LogicalResult Tcgen05RelinquishAllocPermitOp::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.group; auto attr = dict.get("group"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `group` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Tcgen05RelinquishAllocPermitOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.group; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("group", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Tcgen05RelinquishAllocPermitOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.group.getAsOpaquePointer())); } std::optional Tcgen05RelinquishAllocPermitOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "group") return prop.group; return std::nullopt; } void Tcgen05RelinquishAllocPermitOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "group") { prop.group = ::llvm::dyn_cast_or_null>(value); return; } } void Tcgen05RelinquishAllocPermitOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.group) attrs.append("group", prop.group); } ::llvm::LogicalResult Tcgen05RelinquishAllocPermitOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getGroupAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(attr, "group", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05RelinquishAllocPermitOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.group))) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05RelinquishAllocPermitOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.group); } ::mlir::NVVM::CTAGroupKind Tcgen05RelinquishAllocPermitOp::getGroup() { auto attr = getGroupAttr(); return attr.getValue(); } void Tcgen05RelinquishAllocPermitOp::setGroup(::mlir::NVVM::CTAGroupKind attrValue) { getProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05RelinquishAllocPermitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::CTAGroupKindAttr group) { if (group) { odsState.getOrAddProperties().group = group; } } Tcgen05RelinquishAllocPermitOp Tcgen05RelinquishAllocPermitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::CTAGroupKindAttr group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05RelinquishAllocPermitOp Tcgen05RelinquishAllocPermitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::CTAGroupKindAttr group) { return create(builder, builder.getLoc(), std::forward(group)); } void Tcgen05RelinquishAllocPermitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::CTAGroupKindAttr group) { if (group) { odsState.getOrAddProperties().group = group; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05RelinquishAllocPermitOp Tcgen05RelinquishAllocPermitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::CTAGroupKindAttr group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05RelinquishAllocPermitOp Tcgen05RelinquishAllocPermitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::CTAGroupKindAttr group) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(group)); } void Tcgen05RelinquishAllocPermitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::CTAGroupKind group) { odsState.getOrAddProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), group); } Tcgen05RelinquishAllocPermitOp Tcgen05RelinquishAllocPermitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::CTAGroupKind group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05RelinquishAllocPermitOp Tcgen05RelinquishAllocPermitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::CTAGroupKind group) { return create(builder, builder.getLoc(), std::forward(group)); } void Tcgen05RelinquishAllocPermitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::CTAGroupKind group) { odsState.getOrAddProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), group); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05RelinquishAllocPermitOp Tcgen05RelinquishAllocPermitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::CTAGroupKind group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05RelinquishAllocPermitOp Tcgen05RelinquishAllocPermitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::CTAGroupKind group) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(group)); } void Tcgen05RelinquishAllocPermitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05RelinquishAllocPermitOp Tcgen05RelinquishAllocPermitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05RelinquishAllocPermitOp Tcgen05RelinquishAllocPermitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05RelinquishAllocPermitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05RelinquishAllocPermitOp Tcgen05RelinquishAllocPermitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05RelinquishAllocPermitOp Tcgen05RelinquishAllocPermitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Tcgen05RelinquishAllocPermitOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.group) properties.group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), CTAGroupKind::CTA_1); } ::llvm::LogicalResult Tcgen05RelinquishAllocPermitOp::verifyInvariantsImpl() { auto tblgen_group = getProperties().group; (void)tblgen_group; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(*this, tblgen_group, "group"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult Tcgen05RelinquishAllocPermitOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult Tcgen05RelinquishAllocPermitOp::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 Tcgen05RelinquishAllocPermitOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getGroupAttr(); if(attr && (attr == ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), CTAGroupKind::CTA_1))) elidedAttrs.push_back("group"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05RelinquishAllocPermitOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05RelinquishAllocPermitOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05ShiftOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05ShiftOpGenericAdaptorBase::Tcgen05ShiftOpGenericAdaptorBase(Tcgen05ShiftOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::CTAGroupKindAttr Tcgen05ShiftOpGenericAdaptorBase::getGroupAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::NVVM::CTAGroupKindAttr>(getProperties().group); return attr; } ::mlir::NVVM::CTAGroupKind Tcgen05ShiftOpGenericAdaptorBase::getGroup() { auto attr = getGroupAttr(); return attr.getValue(); } } // namespace detail Tcgen05ShiftOpAdaptor::Tcgen05ShiftOpAdaptor(Tcgen05ShiftOp op) : Tcgen05ShiftOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05ShiftOpAdaptor::verify(::mlir::Location loc) { auto tblgen_group = getProperties().group; (void)tblgen_group; if (tblgen_group && !((::llvm::isa<::mlir::NVVM::CTAGroupKindAttr>(tblgen_group)))) return emitError(loc, "'nvvm.tcgen05.shift' op attribute 'group' failed to satisfy constraint: NVVM CTA group kind"); return ::mlir::success(); } ::llvm::LogicalResult Tcgen05ShiftOp::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.group; auto attr = dict.get("group"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `group` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Tcgen05ShiftOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.group; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("group", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Tcgen05ShiftOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.group.getAsOpaquePointer())); } std::optional Tcgen05ShiftOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "group") return prop.group; return std::nullopt; } void Tcgen05ShiftOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "group") { prop.group = ::llvm::dyn_cast_or_null>(value); return; } } void Tcgen05ShiftOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.group) attrs.append("group", prop.group); } ::llvm::LogicalResult Tcgen05ShiftOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getGroupAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(attr, "group", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05ShiftOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.group))) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05ShiftOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.group); } ::mlir::NVVM::CTAGroupKind Tcgen05ShiftOp::getGroup() { auto attr = getGroupAttr(); return attr.getValue(); } void Tcgen05ShiftOp::setGroup(::mlir::NVVM::CTAGroupKind attrValue) { getProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05ShiftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value taddr, ::mlir::NVVM::CTAGroupKindAttr group) { odsState.addOperands(taddr); if (group) { odsState.getOrAddProperties().group = group; } } Tcgen05ShiftOp Tcgen05ShiftOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value taddr, ::mlir::NVVM::CTAGroupKindAttr group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(taddr), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05ShiftOp Tcgen05ShiftOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value taddr, ::mlir::NVVM::CTAGroupKindAttr group) { return create(builder, builder.getLoc(), std::forward(taddr), std::forward(group)); } void Tcgen05ShiftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value taddr, ::mlir::NVVM::CTAGroupKindAttr group) { odsState.addOperands(taddr); if (group) { odsState.getOrAddProperties().group = group; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05ShiftOp Tcgen05ShiftOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value taddr, ::mlir::NVVM::CTAGroupKindAttr group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(taddr), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05ShiftOp Tcgen05ShiftOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value taddr, ::mlir::NVVM::CTAGroupKindAttr group) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(taddr), std::forward(group)); } void Tcgen05ShiftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value taddr, ::mlir::NVVM::CTAGroupKind group) { odsState.addOperands(taddr); odsState.getOrAddProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), group); } Tcgen05ShiftOp Tcgen05ShiftOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value taddr, ::mlir::NVVM::CTAGroupKind group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(taddr), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05ShiftOp Tcgen05ShiftOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value taddr, ::mlir::NVVM::CTAGroupKind group) { return create(builder, builder.getLoc(), std::forward(taddr), std::forward(group)); } void Tcgen05ShiftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value taddr, ::mlir::NVVM::CTAGroupKind group) { odsState.addOperands(taddr); odsState.getOrAddProperties().group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), group); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05ShiftOp Tcgen05ShiftOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value taddr, ::mlir::NVVM::CTAGroupKind group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(taddr), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05ShiftOp Tcgen05ShiftOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value taddr, ::mlir::NVVM::CTAGroupKind group) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(taddr), std::forward(group)); } void Tcgen05ShiftOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05ShiftOp Tcgen05ShiftOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05ShiftOp Tcgen05ShiftOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05ShiftOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05ShiftOp Tcgen05ShiftOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05ShiftOp Tcgen05ShiftOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void Tcgen05ShiftOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.group) properties.group = ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), CTAGroupKind::CTA_1); } ::llvm::LogicalResult Tcgen05ShiftOp::verifyInvariantsImpl() { auto tblgen_group = getProperties().group; (void)tblgen_group; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps19(*this, tblgen_group, "group"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05ShiftOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult Tcgen05ShiftOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand taddrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> taddrOperands(&taddrRawOperand, 1); ::llvm::SMLoc taddrOperandsLoc; (void)taddrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; taddrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(taddrRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.resolveOperands(taddrOperands, allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05ShiftOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getTaddr(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getGroupAttr(); if(attr && (attr == ::mlir::NVVM::CTAGroupKindAttr::get(odsBuilder.getContext(), CTAGroupKind::CTA_1))) elidedAttrs.push_back("group"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05ShiftOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05ShiftOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05StOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05StOpGenericAdaptorBase::Tcgen05StOpGenericAdaptorBase(Tcgen05StOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair Tcgen05StOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::UnitAttr Tcgen05StOpGenericAdaptorBase::getUnpackAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().unpack); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool Tcgen05StOpGenericAdaptorBase::getUnpack() { auto attr = getUnpackAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::mlir::NVVM::Tcgen05LdStShape Tcgen05StOpGenericAdaptorBase::getShape() { auto attr = getShapeAttr(); return attr.getValue(); } } // namespace detail Tcgen05StOpAdaptor::Tcgen05StOpAdaptor(Tcgen05StOp op) : Tcgen05StOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05StOpAdaptor::verify(::mlir::Location loc) { auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitError(loc, "'nvvm.tcgen05.st' op requires attribute 'shape'"); auto tblgen_unpack = getProperties().unpack; (void)tblgen_unpack; if (tblgen_unpack && !((::llvm::isa<::mlir::UnitAttr>(tblgen_unpack)))) return emitError(loc, "'nvvm.tcgen05.st' op attribute 'unpack' failed to satisfy constraint: unit attribute"); if (tblgen_shape && !((::llvm::isa<::mlir::NVVM::Tcgen05LdStShapeAttr>(tblgen_shape)))) return emitError(loc, "'nvvm.tcgen05.st' op attribute 'shape' failed to satisfy constraint: allowed 32-bit signless integer cases: 0, 1, 2, 3, 4"); return ::mlir::success(); } std::pair Tcgen05StOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange Tcgen05StOp::getOffsetMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult Tcgen05StOp::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.shape; auto attr = dict.get("shape"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `shape` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.unpack; auto attr = dict.get("unpack"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `unpack` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Tcgen05StOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.shape; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("shape", propStorage)); } { const auto &propStorage = prop.unpack; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("unpack", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Tcgen05StOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.shape.getAsOpaquePointer()), llvm::hash_value(prop.unpack.getAsOpaquePointer())); } std::optional Tcgen05StOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "shape") return prop.shape; if (name == "unpack") return prop.unpack; return std::nullopt; } void Tcgen05StOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "shape") { prop.shape = ::llvm::dyn_cast_or_null>(value); return; } if (name == "unpack") { prop.unpack = ::llvm::dyn_cast_or_null>(value); return; } } void Tcgen05StOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.shape) attrs.append("shape", prop.shape); if (prop.unpack) attrs.append("unpack", prop.unpack); } ::llvm::LogicalResult Tcgen05StOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getShapeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps57(attr, "shape", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getUnpackAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(attr, "unpack", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05StOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.shape))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.unpack))) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05StOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.shape); writer.writeOptionalAttribute(prop.unpack); } bool Tcgen05StOp::getUnpack() { auto attr = getUnpackAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::mlir::NVVM::Tcgen05LdStShape Tcgen05StOp::getShape() { auto attr = getShapeAttr(); return attr.getValue(); } void Tcgen05StOp::setUnpack(bool attrValue) { auto &odsProp = getProperties().unpack; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void Tcgen05StOp::setShape(::mlir::NVVM::Tcgen05LdStShape attrValue) { getProperties().shape = ::mlir::NVVM::Tcgen05LdStShapeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05StOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::UnitAttr unpack, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::Value tmemAddr, ::mlir::Value val, /*optional*/::mlir::Value offset) { odsState.addOperands(tmemAddr); odsState.addOperands(val); if (offset) odsState.addOperands(offset); if (unpack) { odsState.getOrAddProperties().unpack = unpack; } odsState.getOrAddProperties().shape = shape; } Tcgen05StOp Tcgen05StOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::UnitAttr unpack, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::Value tmemAddr, ::mlir::Value val, /*optional*/::mlir::Value offset) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(unpack), std::forward(shape), std::forward(tmemAddr), std::forward(val), std::forward(offset)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05StOp Tcgen05StOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::UnitAttr unpack, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::Value tmemAddr, ::mlir::Value val, /*optional*/::mlir::Value offset) { return create(builder, builder.getLoc(), std::forward(unpack), std::forward(shape), std::forward(tmemAddr), std::forward(val), std::forward(offset)); } void Tcgen05StOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr unpack, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::Value tmemAddr, ::mlir::Value val, /*optional*/::mlir::Value offset) { odsState.addOperands(tmemAddr); odsState.addOperands(val); if (offset) odsState.addOperands(offset); if (unpack) { odsState.getOrAddProperties().unpack = unpack; } odsState.getOrAddProperties().shape = shape; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05StOp Tcgen05StOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr unpack, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::Value tmemAddr, ::mlir::Value val, /*optional*/::mlir::Value offset) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(unpack), std::forward(shape), std::forward(tmemAddr), std::forward(val), std::forward(offset)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05StOp Tcgen05StOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::UnitAttr unpack, ::mlir::NVVM::Tcgen05LdStShapeAttr shape, ::mlir::Value tmemAddr, ::mlir::Value val, /*optional*/::mlir::Value offset) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(unpack), std::forward(shape), std::forward(tmemAddr), std::forward(val), std::forward(offset)); } void Tcgen05StOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/bool unpack, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::Value tmemAddr, ::mlir::Value val, /*optional*/::mlir::Value offset) { odsState.addOperands(tmemAddr); odsState.addOperands(val); if (offset) odsState.addOperands(offset); if (unpack) { odsState.getOrAddProperties().unpack = ((unpack) ? odsBuilder.getUnitAttr() : nullptr); } odsState.getOrAddProperties().shape = ::mlir::NVVM::Tcgen05LdStShapeAttr::get(odsBuilder.getContext(), shape); } Tcgen05StOp Tcgen05StOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/bool unpack, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::Value tmemAddr, ::mlir::Value val, /*optional*/::mlir::Value offset) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(unpack), std::forward(shape), std::forward(tmemAddr), std::forward(val), std::forward(offset)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05StOp Tcgen05StOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/bool unpack, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::Value tmemAddr, ::mlir::Value val, /*optional*/::mlir::Value offset) { return create(builder, builder.getLoc(), std::forward(unpack), std::forward(shape), std::forward(tmemAddr), std::forward(val), std::forward(offset)); } void Tcgen05StOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/bool unpack, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::Value tmemAddr, ::mlir::Value val, /*optional*/::mlir::Value offset) { odsState.addOperands(tmemAddr); odsState.addOperands(val); if (offset) odsState.addOperands(offset); if (unpack) { odsState.getOrAddProperties().unpack = ((unpack) ? odsBuilder.getUnitAttr() : nullptr); } odsState.getOrAddProperties().shape = ::mlir::NVVM::Tcgen05LdStShapeAttr::get(odsBuilder.getContext(), shape); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05StOp Tcgen05StOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/bool unpack, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::Value tmemAddr, ::mlir::Value val, /*optional*/::mlir::Value offset) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(unpack), std::forward(shape), std::forward(tmemAddr), std::forward(val), std::forward(offset)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05StOp Tcgen05StOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/bool unpack, ::mlir::NVVM::Tcgen05LdStShape shape, ::mlir::Value tmemAddr, ::mlir::Value val, /*optional*/::mlir::Value offset) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(unpack), std::forward(shape), std::forward(tmemAddr), std::forward(val), std::forward(offset)); } void Tcgen05StOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05StOp Tcgen05StOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05StOp Tcgen05StOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05StOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05StOp Tcgen05StOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05StOp Tcgen05StOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult Tcgen05StOp::verifyInvariantsImpl() { auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitOpError("requires attribute 'shape'"); auto tblgen_unpack = getProperties().unpack; (void)tblgen_unpack; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps7(*this, tblgen_unpack, "unpack"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps57(*this, tblgen_shape, "shape"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps40(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps41(*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_NVVMOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05StOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult Tcgen05StOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand tmemAddrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tmemAddrOperands(&tmemAddrRawOperand, 1); ::llvm::SMLoc tmemAddrOperandsLoc; (void)tmemAddrOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand valRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valOperands(&valRawOperand, 1); ::llvm::SMLoc valOperandsLoc; (void)valOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> offsetOperands; ::llvm::SMLoc offsetOperandsLoc; (void)offsetOperandsLoc; ::mlir::Type valRawType{}; ::llvm::ArrayRef<::mlir::Type> valTypes(&valRawType, 1); tmemAddrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(tmemAddrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); valOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(valRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalComma())) { { offsetOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); offsetOperands.push_back(operand); } } } if (::mlir::succeeded(parser.parseOptionalKeyword("unpack"))) { result.getOrAddProperties().unpack = parser.getBuilder().getUnitAttr(); } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); valRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::LLVM::LLVMPointerType>(6); ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(64); if (parser.resolveOperands(tmemAddrOperands, odsBuildableType0, tmemAddrOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(valOperands, valTypes, valOperandsLoc, result.operands)) return ::mlir::failure(); if (!offsetOperands.empty()) { if (parser.resolveOperands(offsetOperands, odsBuildableType1, offsetOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void Tcgen05StOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getTmemAddr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getVal(); if (getOffset()) { _odsPrinter << ","; _odsPrinter << ' '; if (::mlir::Value value = getOffset()) _odsPrinter << value; } if ((getUnpackAttr() && getUnpackAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "unpack"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("unpack"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getUnpackAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("unpack"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getVal().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05StOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05StOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::Tcgen05WaitOp definitions //===----------------------------------------------------------------------===// namespace detail { Tcgen05WaitOpGenericAdaptorBase::Tcgen05WaitOpGenericAdaptorBase(Tcgen05WaitOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::Tcgen05WaitKind Tcgen05WaitOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } } // namespace detail Tcgen05WaitOpAdaptor::Tcgen05WaitOpAdaptor(Tcgen05WaitOp op) : Tcgen05WaitOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult Tcgen05WaitOpAdaptor::verify(::mlir::Location loc) { auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'nvvm.tcgen05.wait' op requires attribute 'kind'"); if (tblgen_kind && !((::llvm::isa<::mlir::NVVM::Tcgen05WaitKindAttr>(tblgen_kind)))) return emitError(loc, "'nvvm.tcgen05.wait' op attribute 'kind' failed to satisfy constraint: NVVM Tcgen05 wait kind"); return ::mlir::success(); } ::llvm::LogicalResult Tcgen05WaitOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute Tcgen05WaitOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code Tcgen05WaitOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.kind.getAsOpaquePointer())); } std::optional Tcgen05WaitOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "kind") return prop.kind; return std::nullopt; } void Tcgen05WaitOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } } void Tcgen05WaitOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.kind) attrs.append("kind", prop.kind); } ::llvm::LogicalResult Tcgen05WaitOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps63(attr, "kind", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult Tcgen05WaitOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.kind))) return ::mlir::failure(); return ::mlir::success(); } void Tcgen05WaitOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.kind); } ::mlir::NVVM::Tcgen05WaitKind Tcgen05WaitOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } void Tcgen05WaitOp::setKind(::mlir::NVVM::Tcgen05WaitKind attrValue) { getProperties().kind = ::mlir::NVVM::Tcgen05WaitKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void Tcgen05WaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05WaitKindAttr kind) { odsState.getOrAddProperties().kind = kind; } Tcgen05WaitOp Tcgen05WaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05WaitKindAttr kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05WaitOp Tcgen05WaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05WaitKindAttr kind) { return create(builder, builder.getLoc(), std::forward(kind)); } void Tcgen05WaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05WaitKindAttr kind) { odsState.getOrAddProperties().kind = kind; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05WaitOp Tcgen05WaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05WaitKindAttr kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05WaitOp Tcgen05WaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05WaitKindAttr kind) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind)); } void Tcgen05WaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::Tcgen05WaitKind kind) { odsState.getOrAddProperties().kind = ::mlir::NVVM::Tcgen05WaitKindAttr::get(odsBuilder.getContext(), kind); } Tcgen05WaitOp Tcgen05WaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::Tcgen05WaitKind kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05WaitOp Tcgen05WaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::Tcgen05WaitKind kind) { return create(builder, builder.getLoc(), std::forward(kind)); } void Tcgen05WaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05WaitKind kind) { odsState.getOrAddProperties().kind = ::mlir::NVVM::Tcgen05WaitKindAttr::get(odsBuilder.getContext(), kind); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } Tcgen05WaitOp Tcgen05WaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05WaitKind kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05WaitOp Tcgen05WaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::Tcgen05WaitKind kind) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind)); } void Tcgen05WaitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } Tcgen05WaitOp Tcgen05WaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05WaitOp Tcgen05WaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void Tcgen05WaitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } Tcgen05WaitOp Tcgen05WaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } Tcgen05WaitOp Tcgen05WaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult Tcgen05WaitOp::verifyInvariantsImpl() { auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps63(*this, tblgen_kind, "kind"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult Tcgen05WaitOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult Tcgen05WaitOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::Tcgen05WaitKindAttr kindAttr; if (parser.parseCustomAttributeWithFallback(kindAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (kindAttr) result.getOrAddProperties().kind = kindAttr; { 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 Tcgen05WaitOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getKindAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("kind"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::Tcgen05WaitOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::Tcgen05WaitOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::TensormapReplaceOp definitions //===----------------------------------------------------------------------===// namespace detail { TensormapReplaceOpGenericAdaptorBase::TensormapReplaceOpGenericAdaptorBase(TensormapReplaceOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair TensormapReplaceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::NVVM::TensormapField TensormapReplaceOpGenericAdaptorBase::getField() { auto attr = getFieldAttr(); return attr.getValue(); } ::std::optional TensormapReplaceOpGenericAdaptorBase::getOrd() { auto attr = getOrdAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } ::std::optional<::mlir::Attribute> TensormapReplaceOpGenericAdaptorBase::getNewValueAttr() { auto attr = getNewValueAttrAttr(); return attr ? ::std::optional<::mlir::Attribute>(attr) : (::std::nullopt); } } // namespace detail TensormapReplaceOpAdaptor::TensormapReplaceOpAdaptor(TensormapReplaceOp op) : TensormapReplaceOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult TensormapReplaceOpAdaptor::verify(::mlir::Location loc) { auto tblgen_field = getProperties().field; (void)tblgen_field; if (!tblgen_field) return emitError(loc, "'nvvm.tensormap.replace' op requires attribute 'field'"); auto tblgen_new_value_attr = getProperties().new_value_attr; (void)tblgen_new_value_attr; auto tblgen_ord = getProperties().ord; (void)tblgen_ord; if (tblgen_field && !((::llvm::isa<::mlir::NVVM::TensormapFieldAttr>(tblgen_field)))) return emitError(loc, "'nvvm.tensormap.replace' op attribute 'field' failed to satisfy constraint: NVVM Tensormap Field Kind"); if (tblgen_ord && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_ord))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_ord).getType().isSignlessInteger(32)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_ord).getInt() >= 0)) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_ord).getInt() <= 4)))) return emitError(loc, "'nvvm.tensormap.replace' op attribute 'ord' failed to satisfy constraint: 32-bit signless integer attribute whose minimum value is 0 whose maximum value is 4"); if (tblgen_new_value_attr && !(((::llvm::isa<::mlir::NVVM::TensormapElemtypeAttr>(tblgen_new_value_attr))) || ((::llvm::isa<::mlir::NVVM::TensormapInterleaveLayoutAttr>(tblgen_new_value_attr))) || ((::llvm::isa<::mlir::NVVM::TensormapSwizzleModeAttr>(tblgen_new_value_attr))) || ((::llvm::isa<::mlir::NVVM::TensormapSwizzleAtomicityAttr>(tblgen_new_value_attr))) || ((::llvm::isa<::mlir::NVVM::TensormapFillModeAttr>(tblgen_new_value_attr))))) return emitError(loc, "'nvvm.tensormap.replace' op attribute 'new_value_attr' failed to satisfy constraint: NVVM Tensormap Elemtype or NVVM Tensormap Interleave Layout or NVVM Tensormap Swizzle Mode or NVVM Tensormap Swizzle Atomicity or NVVM Tensormap Fill Mode"); return ::mlir::success(); } std::pair TensormapReplaceOp::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 TensormapReplaceOp::getNewValueMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult TensormapReplaceOp::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.field; auto attr = dict.get("field"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `field` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.new_value_attr; auto attr = dict.get("new_value_attr"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `new_value_attr` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.ord; auto attr = dict.get("ord"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ord` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute TensormapReplaceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.field; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("field", propStorage)); } { const auto &propStorage = prop.new_value_attr; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("new_value_attr", propStorage)); } { const auto &propStorage = prop.ord; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ord", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code TensormapReplaceOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.field.getAsOpaquePointer()), llvm::hash_value(prop.new_value_attr.getAsOpaquePointer()), llvm::hash_value(prop.ord.getAsOpaquePointer())); } std::optional TensormapReplaceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "field") return prop.field; if (name == "new_value_attr") return prop.new_value_attr; if (name == "ord") return prop.ord; return std::nullopt; } void TensormapReplaceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "field") { prop.field = ::llvm::dyn_cast_or_null>(value); return; } if (name == "new_value_attr") { prop.new_value_attr = ::llvm::dyn_cast_or_null>(value); return; } if (name == "ord") { prop.ord = ::llvm::dyn_cast_or_null>(value); return; } } void TensormapReplaceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.field) attrs.append("field", prop.field); if (prop.new_value_attr) attrs.append("new_value_attr", prop.new_value_attr); if (prop.ord) attrs.append("ord", prop.ord); } ::llvm::LogicalResult TensormapReplaceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFieldAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps64(attr, "field", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNewValueAttrAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps66(attr, "new_value_attr", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getOrdAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps65(attr, "ord", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult TensormapReplaceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.field))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.new_value_attr))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.ord))) return ::mlir::failure(); return ::mlir::success(); } void TensormapReplaceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.field); writer.writeOptionalAttribute(prop.new_value_attr); writer.writeOptionalAttribute(prop.ord); } ::mlir::NVVM::TensormapField TensormapReplaceOp::getField() { auto attr = getFieldAttr(); return attr.getValue(); } ::std::optional TensormapReplaceOp::getOrd() { auto attr = getOrdAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } ::std::optional<::mlir::Attribute> TensormapReplaceOp::getNewValueAttr() { auto attr = getNewValueAttrAttr(); return attr ? ::std::optional<::mlir::Attribute>(attr) : (::std::nullopt); } void TensormapReplaceOp::setField(::mlir::NVVM::TensormapField attrValue) { getProperties().field = ::mlir::NVVM::TensormapFieldAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void TensormapReplaceOp::setOrd(::std::optional attrValue) { auto &odsProp = getProperties().ord; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), *attrValue); else odsProp = nullptr; } void TensormapReplaceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::TensormapFieldAttr field, ::mlir::Value addr, /*optional*/::mlir::Value new_value, /*optional*/::mlir::IntegerAttr ord, /*optional*/::mlir::Attribute new_value_attr) { odsState.addOperands(addr); if (new_value) odsState.addOperands(new_value); odsState.getOrAddProperties().field = field; if (ord) { odsState.getOrAddProperties().ord = ord; } if (new_value_attr) { odsState.getOrAddProperties().new_value_attr = new_value_attr; } } TensormapReplaceOp TensormapReplaceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::TensormapFieldAttr field, ::mlir::Value addr, /*optional*/::mlir::Value new_value, /*optional*/::mlir::IntegerAttr ord, /*optional*/::mlir::Attribute new_value_attr) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(field), std::forward(addr), std::forward(new_value), std::forward(ord), std::forward(new_value_attr)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TensormapReplaceOp TensormapReplaceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::TensormapFieldAttr field, ::mlir::Value addr, /*optional*/::mlir::Value new_value, /*optional*/::mlir::IntegerAttr ord, /*optional*/::mlir::Attribute new_value_attr) { return create(builder, builder.getLoc(), std::forward(field), std::forward(addr), std::forward(new_value), std::forward(ord), std::forward(new_value_attr)); } void TensormapReplaceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::TensormapFieldAttr field, ::mlir::Value addr, /*optional*/::mlir::Value new_value, /*optional*/::mlir::IntegerAttr ord, /*optional*/::mlir::Attribute new_value_attr) { odsState.addOperands(addr); if (new_value) odsState.addOperands(new_value); odsState.getOrAddProperties().field = field; if (ord) { odsState.getOrAddProperties().ord = ord; } if (new_value_attr) { odsState.getOrAddProperties().new_value_attr = new_value_attr; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } TensormapReplaceOp TensormapReplaceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::TensormapFieldAttr field, ::mlir::Value addr, /*optional*/::mlir::Value new_value, /*optional*/::mlir::IntegerAttr ord, /*optional*/::mlir::Attribute new_value_attr) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(field), std::forward(addr), std::forward(new_value), std::forward(ord), std::forward(new_value_attr)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TensormapReplaceOp TensormapReplaceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::TensormapFieldAttr field, ::mlir::Value addr, /*optional*/::mlir::Value new_value, /*optional*/::mlir::IntegerAttr ord, /*optional*/::mlir::Attribute new_value_attr) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(field), std::forward(addr), std::forward(new_value), std::forward(ord), std::forward(new_value_attr)); } void TensormapReplaceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::NVVM::TensormapField field, ::mlir::Value addr, /*optional*/::mlir::Value new_value, /*optional*/::mlir::IntegerAttr ord, /*optional*/::mlir::Attribute new_value_attr) { odsState.addOperands(addr); if (new_value) odsState.addOperands(new_value); odsState.getOrAddProperties().field = ::mlir::NVVM::TensormapFieldAttr::get(odsBuilder.getContext(), field); if (ord) { odsState.getOrAddProperties().ord = ord; } if (new_value_attr) { odsState.getOrAddProperties().new_value_attr = new_value_attr; } } TensormapReplaceOp TensormapReplaceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::NVVM::TensormapField field, ::mlir::Value addr, /*optional*/::mlir::Value new_value, /*optional*/::mlir::IntegerAttr ord, /*optional*/::mlir::Attribute new_value_attr) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(field), std::forward(addr), std::forward(new_value), std::forward(ord), std::forward(new_value_attr)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TensormapReplaceOp TensormapReplaceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::NVVM::TensormapField field, ::mlir::Value addr, /*optional*/::mlir::Value new_value, /*optional*/::mlir::IntegerAttr ord, /*optional*/::mlir::Attribute new_value_attr) { return create(builder, builder.getLoc(), std::forward(field), std::forward(addr), std::forward(new_value), std::forward(ord), std::forward(new_value_attr)); } void TensormapReplaceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::NVVM::TensormapField field, ::mlir::Value addr, /*optional*/::mlir::Value new_value, /*optional*/::mlir::IntegerAttr ord, /*optional*/::mlir::Attribute new_value_attr) { odsState.addOperands(addr); if (new_value) odsState.addOperands(new_value); odsState.getOrAddProperties().field = ::mlir::NVVM::TensormapFieldAttr::get(odsBuilder.getContext(), field); if (ord) { odsState.getOrAddProperties().ord = ord; } if (new_value_attr) { odsState.getOrAddProperties().new_value_attr = new_value_attr; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } TensormapReplaceOp TensormapReplaceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::NVVM::TensormapField field, ::mlir::Value addr, /*optional*/::mlir::Value new_value, /*optional*/::mlir::IntegerAttr ord, /*optional*/::mlir::Attribute new_value_attr) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(field), std::forward(addr), std::forward(new_value), std::forward(ord), std::forward(new_value_attr)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TensormapReplaceOp TensormapReplaceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::NVVM::TensormapField field, ::mlir::Value addr, /*optional*/::mlir::Value new_value, /*optional*/::mlir::IntegerAttr ord, /*optional*/::mlir::Attribute new_value_attr) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(field), std::forward(addr), std::forward(new_value), std::forward(ord), std::forward(new_value_attr)); } void TensormapReplaceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } TensormapReplaceOp TensormapReplaceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TensormapReplaceOp TensormapReplaceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void TensormapReplaceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } TensormapReplaceOp TensormapReplaceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TensormapReplaceOp TensormapReplaceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult TensormapReplaceOp::verifyInvariantsImpl() { auto tblgen_field = getProperties().field; (void)tblgen_field; if (!tblgen_field) return emitOpError("requires attribute 'field'"); auto tblgen_new_value_attr = getProperties().new_value_attr; (void)tblgen_new_value_attr; auto tblgen_ord = getProperties().ord; (void)tblgen_ord; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps64(*this, tblgen_field, "field"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps65(*this, tblgen_ord, "ord"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps66(*this, tblgen_new_value_attr, "new_value_attr"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps45(*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_NVVMOps30(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult TensormapReplaceOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult TensormapReplaceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::TensormapFieldAttr fieldAttr; ::mlir::IntegerAttr ordAttr; ::mlir::Attribute new_value_attrAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> new_valueOperands; ::llvm::SMLoc new_valueOperandsLoc; (void)new_valueOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand addrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> addrOperands(&addrRawOperand, 1); ::llvm::SMLoc addrOperandsLoc; (void)addrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; if (parser.parseKeyword("field")) return ::mlir::failure(); if (parser.parseEqual()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(fieldAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fieldAttr) result.getOrAddProperties().field = fieldAttr; if (::mlir::succeeded(parser.parseOptionalLSquare())) { if (parser.parseCustomAttributeWithFallback(ordAttr, parser.getBuilder().getIntegerType(32))) { return ::mlir::failure(); } if (ordAttr) result.getOrAddProperties().ord = ordAttr; if (parser.parseRSquare()) return ::mlir::failure(); } if (parser.parseComma()) return ::mlir::failure(); if (parser.parseKeyword("new_value")) return ::mlir::failure(); if (parser.parseEqual()) return ::mlir::failure(); ::mlir::OptionalParseResult parseResultnew_value_attrAttr = parser.parseOptionalAttribute(new_value_attrAttr, ::mlir::Type{}); if (parseResultnew_value_attrAttr.has_value() && failed(*parseResultnew_value_attrAttr)) return ::mlir::failure(); if (parseResultnew_value_attrAttr.has_value() && succeeded(*parseResultnew_value_attrAttr)) if (new_value_attrAttr) result.getOrAddProperties().new_value_attr = new_value_attrAttr; if (new_value_attrAttr) { } else { { new_valueOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); new_valueOperands.push_back(operand); } } } if (parser.parseKeyword("in")) return ::mlir::failure(); addrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(addrRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(allOperandTypes)) return ::mlir::failure(); if (parser.resolveOperands(::llvm::concat(addrOperands, new_valueOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void TensormapReplaceOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' ' << "field"; _odsPrinter << ' ' << "="; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getFieldAttr()); if (getOrdAttr()) { _odsPrinter << "["; _odsPrinter.printAttributeWithoutType(getOrdAttr()); _odsPrinter << "]"; } _odsPrinter << ","; _odsPrinter << ' ' << "new_value"; _odsPrinter << ' ' << "="; if (getNewValueAttrAttr()) { _odsPrinter << ' '; _odsPrinter.printAttribute(getNewValueAttrAttr()); } else { _odsPrinter << ' '; if (::mlir::Value value = getNewValue()) _odsPrinter << value; } _odsPrinter << ' ' << "in"; _odsPrinter << ' '; _odsPrinter << getAddr(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("field"); elidedAttrs.push_back("ord"); elidedAttrs.push_back("new_value_attr"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperation()->getOperandTypes(); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::TensormapReplaceOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::TensormapReplaceOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ThreadIdXOp definitions //===----------------------------------------------------------------------===// namespace detail { ThreadIdXOpGenericAdaptorBase::ThreadIdXOpGenericAdaptorBase(ThreadIdXOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> ThreadIdXOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail ThreadIdXOpAdaptor::ThreadIdXOpAdaptor(ThreadIdXOp op) : ThreadIdXOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ThreadIdXOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.tid.x' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult ThreadIdXOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ThreadIdXOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ThreadIdXOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional ThreadIdXOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void ThreadIdXOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void ThreadIdXOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult ThreadIdXOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ThreadIdXOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void ThreadIdXOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> ThreadIdXOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void ThreadIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } ThreadIdXOp ThreadIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdXOp ThreadIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void ThreadIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } ThreadIdXOp ThreadIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdXOp ThreadIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void ThreadIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ThreadIdXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ThreadIdXOp ThreadIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdXOp ThreadIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void ThreadIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ThreadIdXOp ThreadIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdXOp ThreadIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void ThreadIdXOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ThreadIdXOp ThreadIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdXOp ThreadIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ThreadIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ThreadIdXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ThreadIdXOp ThreadIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdXOp ThreadIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ThreadIdXOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ThreadIdXOp ThreadIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdXOp ThreadIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ThreadIdXOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ThreadIdXOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ThreadIdXOp ThreadIdXOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdXOp ThreadIdXOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ThreadIdXOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ThreadIdXOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ThreadIdXOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ThreadIdXOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void ThreadIdXOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ThreadIdXOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void ThreadIdXOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult ThreadIdXOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ThreadIdXOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ThreadIdXOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ThreadIdYOp definitions //===----------------------------------------------------------------------===// namespace detail { ThreadIdYOpGenericAdaptorBase::ThreadIdYOpGenericAdaptorBase(ThreadIdYOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> ThreadIdYOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail ThreadIdYOpAdaptor::ThreadIdYOpAdaptor(ThreadIdYOp op) : ThreadIdYOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ThreadIdYOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.tid.y' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult ThreadIdYOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ThreadIdYOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ThreadIdYOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional ThreadIdYOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void ThreadIdYOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void ThreadIdYOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult ThreadIdYOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ThreadIdYOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void ThreadIdYOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> ThreadIdYOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void ThreadIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } ThreadIdYOp ThreadIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdYOp ThreadIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void ThreadIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } ThreadIdYOp ThreadIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdYOp ThreadIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void ThreadIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ThreadIdYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ThreadIdYOp ThreadIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdYOp ThreadIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void ThreadIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ThreadIdYOp ThreadIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdYOp ThreadIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void ThreadIdYOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ThreadIdYOp ThreadIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdYOp ThreadIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ThreadIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ThreadIdYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ThreadIdYOp ThreadIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdYOp ThreadIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ThreadIdYOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ThreadIdYOp ThreadIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdYOp ThreadIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ThreadIdYOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ThreadIdYOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ThreadIdYOp ThreadIdYOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdYOp ThreadIdYOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ThreadIdYOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ThreadIdYOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ThreadIdYOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ThreadIdYOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void ThreadIdYOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ThreadIdYOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void ThreadIdYOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult ThreadIdYOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ThreadIdYOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ThreadIdYOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::ThreadIdZOp definitions //===----------------------------------------------------------------------===// namespace detail { ThreadIdZOpGenericAdaptorBase::ThreadIdZOpGenericAdaptorBase(ThreadIdZOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> ThreadIdZOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail ThreadIdZOpAdaptor::ThreadIdZOpAdaptor(ThreadIdZOp op) : ThreadIdZOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ThreadIdZOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.tid.z' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult ThreadIdZOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ThreadIdZOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ThreadIdZOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional ThreadIdZOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void ThreadIdZOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void ThreadIdZOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult ThreadIdZOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ThreadIdZOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void ThreadIdZOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> ThreadIdZOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void ThreadIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } ThreadIdZOp ThreadIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdZOp ThreadIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void ThreadIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } ThreadIdZOp ThreadIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdZOp ThreadIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void ThreadIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ThreadIdZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ThreadIdZOp ThreadIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdZOp ThreadIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void ThreadIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ThreadIdZOp ThreadIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdZOp ThreadIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void ThreadIdZOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ThreadIdZOp ThreadIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdZOp ThreadIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ThreadIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ThreadIdZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ThreadIdZOp ThreadIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdZOp ThreadIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ThreadIdZOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ThreadIdZOp ThreadIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdZOp ThreadIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ThreadIdZOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ThreadIdZOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ThreadIdZOp ThreadIdZOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ThreadIdZOp ThreadIdZOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ThreadIdZOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ThreadIdZOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ThreadIdZOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ThreadIdZOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void ThreadIdZOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ThreadIdZOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void ThreadIdZOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult ThreadIdZOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::ThreadIdZOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::ThreadIdZOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::TotalSmemSize definitions //===----------------------------------------------------------------------===// namespace detail { TotalSmemSizeGenericAdaptorBase::TotalSmemSizeGenericAdaptorBase(TotalSmemSize op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail TotalSmemSizeAdaptor::TotalSmemSizeAdaptor(TotalSmemSize op) : TotalSmemSizeGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult TotalSmemSizeAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult TotalSmemSize::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 TotalSmemSize::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 TotalSmemSize::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional TotalSmemSize::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void TotalSmemSize::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void TotalSmemSize::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult TotalSmemSize::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void TotalSmemSize::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { odsState.addTypes(res); } TotalSmemSize TotalSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TotalSmemSize TotalSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res) { return create(builder, builder.getLoc(), std::forward(res)); } void TotalSmemSize::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(TotalSmemSize::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } TotalSmemSize TotalSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TotalSmemSize TotalSmemSize::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void TotalSmemSize::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } TotalSmemSize TotalSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TotalSmemSize TotalSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void TotalSmemSize::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); } TotalSmemSize TotalSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TotalSmemSize TotalSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void TotalSmemSize::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(TotalSmemSize::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } TotalSmemSize TotalSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TotalSmemSize TotalSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void TotalSmemSize::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } TotalSmemSize TotalSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TotalSmemSize TotalSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void TotalSmemSize::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(TotalSmemSize::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } TotalSmemSize TotalSmemSize::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TotalSmemSize TotalSmemSize::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult TotalSmemSize::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult TotalSmemSize::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult TotalSmemSize::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult TotalSmemSize::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::IntegerType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void TotalSmemSize::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void TotalSmemSize::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::TotalSmemSize) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::VoteSyncOp definitions //===----------------------------------------------------------------------===// namespace detail { VoteSyncOpGenericAdaptorBase::VoteSyncOpGenericAdaptorBase(VoteSyncOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::VoteSyncKind VoteSyncOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } } // namespace detail VoteSyncOpAdaptor::VoteSyncOpAdaptor(VoteSyncOp op) : VoteSyncOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult VoteSyncOpAdaptor::verify(::mlir::Location loc) { auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'nvvm.vote.sync' op requires attribute 'kind'"); if (tblgen_kind && !((::llvm::isa<::mlir::NVVM::VoteSyncKindAttr>(tblgen_kind)))) return emitError(loc, "'nvvm.vote.sync' op attribute 'kind' failed to satisfy constraint: NVVM vote sync kind"); return ::mlir::success(); } ::llvm::LogicalResult VoteSyncOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute VoteSyncOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code VoteSyncOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.kind.getAsOpaquePointer())); } std::optional VoteSyncOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "kind") return prop.kind; return std::nullopt; } void VoteSyncOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } } void VoteSyncOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.kind) attrs.append("kind", prop.kind); } ::llvm::LogicalResult VoteSyncOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps67(attr, "kind", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult VoteSyncOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.kind))) return ::mlir::failure(); return ::mlir::success(); } void VoteSyncOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.kind); } ::mlir::NVVM::VoteSyncKind VoteSyncOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } void VoteSyncOp::setKind(::mlir::NVVM::VoteSyncKind attrValue) { getProperties().kind = ::mlir::NVVM::VoteSyncKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void VoteSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKindAttr kind) { odsState.addOperands(mask); odsState.addOperands(pred); odsState.getOrAddProperties().kind = kind; odsState.addTypes(res); } VoteSyncOp VoteSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKindAttr kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(mask), std::forward(pred), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } VoteSyncOp VoteSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKindAttr kind) { return create(builder, builder.getLoc(), std::forward(res), std::forward(mask), std::forward(pred), std::forward(kind)); } void VoteSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKindAttr kind) { odsState.addOperands(mask); odsState.addOperands(pred); odsState.getOrAddProperties().kind = kind; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(VoteSyncOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } VoteSyncOp VoteSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKindAttr kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(mask), std::forward(pred), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } VoteSyncOp VoteSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKindAttr kind) { return create(builder, builder.getLoc(), std::forward(mask), std::forward(pred), std::forward(kind)); } void VoteSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKindAttr kind) { odsState.addOperands(mask); odsState.addOperands(pred); odsState.getOrAddProperties().kind = kind; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } VoteSyncOp VoteSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKindAttr kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(mask), std::forward(pred), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } VoteSyncOp VoteSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKindAttr kind) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(mask), std::forward(pred), std::forward(kind)); } void VoteSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKind kind) { odsState.addOperands(mask); odsState.addOperands(pred); odsState.getOrAddProperties().kind = ::mlir::NVVM::VoteSyncKindAttr::get(odsBuilder.getContext(), kind); odsState.addTypes(res); } VoteSyncOp VoteSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKind kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(mask), std::forward(pred), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } VoteSyncOp VoteSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKind kind) { return create(builder, builder.getLoc(), std::forward(res), std::forward(mask), std::forward(pred), std::forward(kind)); } void VoteSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKind kind) { odsState.addOperands(mask); odsState.addOperands(pred); odsState.getOrAddProperties().kind = ::mlir::NVVM::VoteSyncKindAttr::get(odsBuilder.getContext(), kind); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(VoteSyncOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } VoteSyncOp VoteSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKind kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(mask), std::forward(pred), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } VoteSyncOp VoteSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKind kind) { return create(builder, builder.getLoc(), std::forward(mask), std::forward(pred), std::forward(kind)); } void VoteSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKind kind) { odsState.addOperands(mask); odsState.addOperands(pred); odsState.getOrAddProperties().kind = ::mlir::NVVM::VoteSyncKindAttr::get(odsBuilder.getContext(), kind); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } VoteSyncOp VoteSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKind kind) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(mask), std::forward(pred), std::forward(kind)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } VoteSyncOp VoteSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value mask, ::mlir::Value pred, ::mlir::NVVM::VoteSyncKind kind) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(mask), std::forward(pred), std::forward(kind)); } void VoteSyncOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } VoteSyncOp VoteSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } VoteSyncOp VoteSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void VoteSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(VoteSyncOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } VoteSyncOp VoteSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } VoteSyncOp VoteSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void VoteSyncOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } VoteSyncOp VoteSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } VoteSyncOp VoteSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void VoteSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(VoteSyncOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } VoteSyncOp VoteSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } VoteSyncOp VoteSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult VoteSyncOp::verifyInvariantsImpl() { auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps67(*this, tblgen_kind, "kind"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps23(*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_NVVMOps46(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult VoteSyncOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult VoteSyncOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::NVVM::VoteSyncKindAttr kindAttr; ::mlir::OpAsmParser::UnresolvedOperand maskRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> maskOperands(&maskRawOperand, 1); ::llvm::SMLoc maskOperandsLoc; (void)maskOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand predRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> predOperands(&predRawOperand, 1); ::llvm::SMLoc predOperandsLoc; (void)predOperandsLoc; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (parser.parseCustomAttributeWithFallback(kindAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (kindAttr) result.getOrAddProperties().kind = kindAttr; maskOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(maskRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); predOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(predRawOperand)) 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.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(1); result.addTypes(resTypes); if (parser.resolveOperands(maskOperands, odsBuildableType0, maskOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(predOperands, odsBuildableType1, predOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void VoteSyncOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getKindAttr()); _odsPrinter << ' '; _odsPrinter << getMask(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getPred(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("kind"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } ::llvm::LogicalResult VoteSyncOp::inferReturnTypes(::mlir::MLIRContext *context, std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { VoteSyncOp::Adaptor adaptor(operands, attributes, properties, regions); return VoteSyncOp::inferReturnTypes(context, location, adaptor, inferredReturnTypes); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::VoteSyncOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::VoteSyncOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::WMMALoadOp definitions //===----------------------------------------------------------------------===// namespace detail { WMMALoadOpGenericAdaptorBase::WMMALoadOpGenericAdaptorBase(WMMALoadOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} uint32_t WMMALoadOpGenericAdaptorBase::getM() { auto attr = getMAttr(); return attr.getValue().getZExtValue(); } uint32_t WMMALoadOpGenericAdaptorBase::getN() { auto attr = getNAttr(); return attr.getValue().getZExtValue(); } uint32_t WMMALoadOpGenericAdaptorBase::getK() { auto attr = getKAttr(); return attr.getValue().getZExtValue(); } ::mlir::NVVM::MMALayout WMMALoadOpGenericAdaptorBase::getLayout() { auto attr = getLayoutAttr(); return attr.getValue(); } ::mlir::NVVM::MMATypes WMMALoadOpGenericAdaptorBase::getEltype() { auto attr = getEltypeAttr(); return attr.getValue(); } ::mlir::NVVM::MMAFrag WMMALoadOpGenericAdaptorBase::getFrag() { auto attr = getFragAttr(); return attr.getValue(); } } // namespace detail WMMALoadOpAdaptor::WMMALoadOpAdaptor(WMMALoadOp op) : WMMALoadOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult WMMALoadOpAdaptor::verify(::mlir::Location loc) { auto tblgen_eltype = getProperties().eltype; (void)tblgen_eltype; if (!tblgen_eltype) return emitError(loc, "'nvvm.wmma.load' op requires attribute 'eltype'"); auto tblgen_frag = getProperties().frag; (void)tblgen_frag; if (!tblgen_frag) return emitError(loc, "'nvvm.wmma.load' op requires attribute 'frag'"); auto tblgen_k = getProperties().k; (void)tblgen_k; if (!tblgen_k) return emitError(loc, "'nvvm.wmma.load' op requires attribute 'k'"); auto tblgen_layout = getProperties().layout; (void)tblgen_layout; if (!tblgen_layout) return emitError(loc, "'nvvm.wmma.load' op requires attribute 'layout'"); auto tblgen_m = getProperties().m; (void)tblgen_m; if (!tblgen_m) return emitError(loc, "'nvvm.wmma.load' op requires attribute 'm'"); auto tblgen_n = getProperties().n; (void)tblgen_n; if (!tblgen_n) return emitError(loc, "'nvvm.wmma.load' op requires attribute 'n'"); if (tblgen_m && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_m))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_m).getType().isSignlessInteger(32))))) return emitError(loc, "'nvvm.wmma.load' op attribute 'm' failed to satisfy constraint: 32-bit signless integer attribute"); if (tblgen_n && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_n))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_n).getType().isSignlessInteger(32))))) return emitError(loc, "'nvvm.wmma.load' op attribute 'n' failed to satisfy constraint: 32-bit signless integer attribute"); if (tblgen_k && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_k))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_k).getType().isSignlessInteger(32))))) return emitError(loc, "'nvvm.wmma.load' op attribute 'k' failed to satisfy constraint: 32-bit signless integer attribute"); if (tblgen_layout && !((::llvm::isa<::mlir::NVVM::MMALayoutAttr>(tblgen_layout)))) return emitError(loc, "'nvvm.wmma.load' op attribute 'layout' failed to satisfy constraint: NVVM MMA layout"); if (tblgen_eltype && !((::llvm::isa<::mlir::NVVM::MMATypesAttr>(tblgen_eltype)))) return emitError(loc, "'nvvm.wmma.load' op attribute 'eltype' failed to satisfy constraint: NVVM MMA types"); if (tblgen_frag && !((::llvm::isa<::mlir::NVVM::MMAFragAttr>(tblgen_frag)))) return emitError(loc, "'nvvm.wmma.load' op attribute 'frag' failed to satisfy constraint: NVVM MMA frag type"); return ::mlir::success(); } ::llvm::LogicalResult WMMALoadOp::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.eltype; auto attr = dict.get("eltype"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `eltype` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.frag; auto attr = dict.get("frag"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `frag` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.k; auto attr = dict.get("k"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `k` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.layout; auto attr = dict.get("layout"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `layout` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.m; auto attr = dict.get("m"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `m` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.n; auto attr = dict.get("n"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `n` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute WMMALoadOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.eltype; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("eltype", propStorage)); } { const auto &propStorage = prop.frag; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("frag", propStorage)); } { const auto &propStorage = prop.k; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("k", propStorage)); } { const auto &propStorage = prop.layout; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("layout", propStorage)); } { const auto &propStorage = prop.m; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("m", propStorage)); } { const auto &propStorage = prop.n; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("n", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code WMMALoadOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.eltype.getAsOpaquePointer()), llvm::hash_value(prop.frag.getAsOpaquePointer()), llvm::hash_value(prop.k.getAsOpaquePointer()), llvm::hash_value(prop.layout.getAsOpaquePointer()), llvm::hash_value(prop.m.getAsOpaquePointer()), llvm::hash_value(prop.n.getAsOpaquePointer())); } std::optional WMMALoadOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "eltype") return prop.eltype; if (name == "frag") return prop.frag; if (name == "k") return prop.k; if (name == "layout") return prop.layout; if (name == "m") return prop.m; if (name == "n") return prop.n; return std::nullopt; } void WMMALoadOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "eltype") { prop.eltype = ::llvm::dyn_cast_or_null>(value); return; } if (name == "frag") { prop.frag = ::llvm::dyn_cast_or_null>(value); return; } if (name == "k") { prop.k = ::llvm::dyn_cast_or_null>(value); return; } if (name == "layout") { prop.layout = ::llvm::dyn_cast_or_null>(value); return; } if (name == "m") { prop.m = ::llvm::dyn_cast_or_null>(value); return; } if (name == "n") { prop.n = ::llvm::dyn_cast_or_null>(value); return; } } void WMMALoadOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.eltype) attrs.append("eltype", prop.eltype); if (prop.frag) attrs.append("frag", prop.frag); if (prop.k) attrs.append("k", prop.k); if (prop.layout) attrs.append("layout", prop.layout); if (prop.m) attrs.append("m", prop.m); if (prop.n) attrs.append("n", prop.n); } ::llvm::LogicalResult WMMALoadOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getEltypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(attr, "eltype", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getFragAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps68(attr, "frag", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getKAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(attr, "k", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getLayoutAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(attr, "layout", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getMAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(attr, "m", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(attr, "n", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult WMMALoadOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.eltype))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.frag))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.k))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.layout))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.m))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.n))) return ::mlir::failure(); return ::mlir::success(); } void WMMALoadOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.eltype); writer.writeAttribute(prop.frag); writer.writeAttribute(prop.k); writer.writeAttribute(prop.layout); writer.writeAttribute(prop.m); writer.writeAttribute(prop.n); } uint32_t WMMALoadOp::getM() { auto attr = getMAttr(); return attr.getValue().getZExtValue(); } uint32_t WMMALoadOp::getN() { auto attr = getNAttr(); return attr.getValue().getZExtValue(); } uint32_t WMMALoadOp::getK() { auto attr = getKAttr(); return attr.getValue().getZExtValue(); } ::mlir::NVVM::MMALayout WMMALoadOp::getLayout() { auto attr = getLayoutAttr(); return attr.getValue(); } ::mlir::NVVM::MMATypes WMMALoadOp::getEltype() { auto attr = getEltypeAttr(); return attr.getValue(); } ::mlir::NVVM::MMAFrag WMMALoadOp::getFrag() { auto attr = getFragAttr(); return attr.getValue(); } void WMMALoadOp::setM(uint32_t attrValue) { getProperties().m = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); } void WMMALoadOp::setN(uint32_t attrValue) { getProperties().n = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); } void WMMALoadOp::setK(uint32_t attrValue) { getProperties().k = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); } void WMMALoadOp::setLayout(::mlir::NVVM::MMALayout attrValue) { getProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WMMALoadOp::setEltype(::mlir::NVVM::MMATypes attrValue) { getProperties().eltype = ::mlir::NVVM::MMATypesAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WMMALoadOp::setFrag(::mlir::NVVM::MMAFrag attrValue) { getProperties().frag = ::mlir::NVVM::MMAFragAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WMMALoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value ptr, ::mlir::Value stride, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::MMATypesAttr eltype, ::mlir::NVVM::MMAFragAttr frag) { odsState.addOperands(ptr); odsState.addOperands(stride); odsState.getOrAddProperties().m = m; odsState.getOrAddProperties().n = n; odsState.getOrAddProperties().k = k; odsState.getOrAddProperties().layout = layout; odsState.getOrAddProperties().eltype = eltype; odsState.getOrAddProperties().frag = frag; odsState.addTypes(res); } WMMALoadOp WMMALoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value ptr, ::mlir::Value stride, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::MMATypesAttr eltype, ::mlir::NVVM::MMAFragAttr frag) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(ptr), std::forward(stride), std::forward(m), std::forward(n), std::forward(k), std::forward(layout), std::forward(eltype), std::forward(frag)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMALoadOp WMMALoadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value ptr, ::mlir::Value stride, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::MMATypesAttr eltype, ::mlir::NVVM::MMAFragAttr frag) { return create(builder, builder.getLoc(), std::forward(res), std::forward(ptr), std::forward(stride), std::forward(m), std::forward(n), std::forward(k), std::forward(layout), std::forward(eltype), std::forward(frag)); } void WMMALoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::Value stride, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::MMATypesAttr eltype, ::mlir::NVVM::MMAFragAttr frag) { odsState.addOperands(ptr); odsState.addOperands(stride); odsState.getOrAddProperties().m = m; odsState.getOrAddProperties().n = n; odsState.getOrAddProperties().k = k; odsState.getOrAddProperties().layout = layout; odsState.getOrAddProperties().eltype = eltype; odsState.getOrAddProperties().frag = frag; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } WMMALoadOp WMMALoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::Value stride, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::MMATypesAttr eltype, ::mlir::NVVM::MMAFragAttr frag) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ptr), std::forward(stride), std::forward(m), std::forward(n), std::forward(k), std::forward(layout), std::forward(eltype), std::forward(frag)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMALoadOp WMMALoadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::Value stride, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::MMATypesAttr eltype, ::mlir::NVVM::MMAFragAttr frag) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ptr), std::forward(stride), std::forward(m), std::forward(n), std::forward(k), std::forward(layout), std::forward(eltype), std::forward(frag)); } void WMMALoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value ptr, ::mlir::Value stride, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::MMATypes eltype, ::mlir::NVVM::MMAFrag frag) { odsState.addOperands(ptr); odsState.addOperands(stride); odsState.getOrAddProperties().m = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), m); odsState.getOrAddProperties().n = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), n); odsState.getOrAddProperties().k = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), k); odsState.getOrAddProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layout); odsState.getOrAddProperties().eltype = ::mlir::NVVM::MMATypesAttr::get(odsBuilder.getContext(), eltype); odsState.getOrAddProperties().frag = ::mlir::NVVM::MMAFragAttr::get(odsBuilder.getContext(), frag); odsState.addTypes(res); } WMMALoadOp WMMALoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::Value ptr, ::mlir::Value stride, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::MMATypes eltype, ::mlir::NVVM::MMAFrag frag) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(ptr), std::forward(stride), std::forward(m), std::forward(n), std::forward(k), std::forward(layout), std::forward(eltype), std::forward(frag)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMALoadOp WMMALoadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::Value ptr, ::mlir::Value stride, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::MMATypes eltype, ::mlir::NVVM::MMAFrag frag) { return create(builder, builder.getLoc(), std::forward(res), std::forward(ptr), std::forward(stride), std::forward(m), std::forward(n), std::forward(k), std::forward(layout), std::forward(eltype), std::forward(frag)); } void WMMALoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::Value stride, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::MMATypes eltype, ::mlir::NVVM::MMAFrag frag) { odsState.addOperands(ptr); odsState.addOperands(stride); odsState.getOrAddProperties().m = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), m); odsState.getOrAddProperties().n = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), n); odsState.getOrAddProperties().k = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), k); odsState.getOrAddProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layout); odsState.getOrAddProperties().eltype = ::mlir::NVVM::MMATypesAttr::get(odsBuilder.getContext(), eltype); odsState.getOrAddProperties().frag = ::mlir::NVVM::MMAFragAttr::get(odsBuilder.getContext(), frag); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } WMMALoadOp WMMALoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::Value stride, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::MMATypes eltype, ::mlir::NVVM::MMAFrag frag) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ptr), std::forward(stride), std::forward(m), std::forward(n), std::forward(k), std::forward(layout), std::forward(eltype), std::forward(frag)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMALoadOp WMMALoadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::Value stride, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::MMATypes eltype, ::mlir::NVVM::MMAFrag frag) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ptr), std::forward(stride), std::forward(m), std::forward(n), std::forward(k), std::forward(layout), std::forward(eltype), std::forward(frag)); } void WMMALoadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } WMMALoadOp WMMALoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMALoadOp WMMALoadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void WMMALoadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } WMMALoadOp WMMALoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMALoadOp WMMALoadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult WMMALoadOp::verifyInvariantsImpl() { auto tblgen_eltype = getProperties().eltype; (void)tblgen_eltype; if (!tblgen_eltype) return emitOpError("requires attribute 'eltype'"); auto tblgen_frag = getProperties().frag; (void)tblgen_frag; if (!tblgen_frag) return emitOpError("requires attribute 'frag'"); auto tblgen_k = getProperties().k; (void)tblgen_k; if (!tblgen_k) return emitOpError("requires attribute 'k'"); auto tblgen_layout = getProperties().layout; (void)tblgen_layout; if (!tblgen_layout) return emitOpError("requires attribute 'layout'"); auto tblgen_m = getProperties().m; (void)tblgen_m; if (!tblgen_m) return emitOpError("requires attribute 'm'"); auto tblgen_n = getProperties().n; (void)tblgen_n; if (!tblgen_n) return emitOpError("requires attribute 'n'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(*this, tblgen_m, "m"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(*this, tblgen_n, "n"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(*this, tblgen_k, "k"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(*this, tblgen_layout, "layout"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(*this, tblgen_eltype, "eltype"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps68(*this, tblgen_frag, "frag"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps24(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*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_NVVMOps47(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult WMMALoadOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult WMMALoadOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand ptrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> ptrOperands(&ptrRawOperand, 1); ::llvm::SMLoc ptrOperandsLoc; (void)ptrOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand strideRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> strideOperands(&strideRawOperand, 1); ::llvm::SMLoc strideOperandsLoc; (void)strideOperandsLoc; ::llvm::ArrayRef<::mlir::Type> ptrTypes; ::llvm::ArrayRef<::mlir::Type> resTypes; ptrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(ptrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); strideOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(strideRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); ::mlir::FunctionType ptr__res_functionType; if (parser.parseType(ptr__res_functionType)) return ::mlir::failure(); ptrTypes = ptr__res_functionType.getInputs(); resTypes = ptr__res_functionType.getResults(); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); result.addTypes(resTypes); if (parser.resolveOperands(ptrOperands, ptrTypes, ptrOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(strideOperands, odsBuildableType0, strideOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void WMMALoadOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getPtr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getStride(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter.printFunctionalType(::llvm::ArrayRef<::mlir::Type>(getPtr().getType()), ::llvm::ArrayRef<::mlir::Type>(getRes().getType())); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::WMMALoadOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::WMMALoadOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::WMMAMmaOp definitions //===----------------------------------------------------------------------===// namespace detail { WMMAMmaOpGenericAdaptorBase::WMMAMmaOpGenericAdaptorBase(WMMAMmaOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair WMMAMmaOpGenericAdaptorBase::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}; } uint32_t WMMAMmaOpGenericAdaptorBase::getM() { auto attr = getMAttr(); return attr.getValue().getZExtValue(); } uint32_t WMMAMmaOpGenericAdaptorBase::getN() { auto attr = getNAttr(); return attr.getValue().getZExtValue(); } uint32_t WMMAMmaOpGenericAdaptorBase::getK() { auto attr = getKAttr(); return attr.getValue().getZExtValue(); } ::mlir::NVVM::MMALayout WMMAMmaOpGenericAdaptorBase::getLayoutA() { auto attr = getLayoutAAttr(); return attr.getValue(); } ::mlir::NVVM::MMALayout WMMAMmaOpGenericAdaptorBase::getLayoutB() { auto attr = getLayoutBAttr(); return attr.getValue(); } ::mlir::NVVM::MMATypes WMMAMmaOpGenericAdaptorBase::getEltypeA() { auto attr = getEltypeAAttr(); return attr.getValue(); } ::mlir::NVVM::MMATypes WMMAMmaOpGenericAdaptorBase::getEltypeB() { auto attr = getEltypeBAttr(); return attr.getValue(); } } // namespace detail WMMAMmaOpAdaptor::WMMAMmaOpAdaptor(WMMAMmaOp op) : WMMAMmaOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult WMMAMmaOpAdaptor::verify(::mlir::Location loc) { auto tblgen_eltypeA = getProperties().eltypeA; (void)tblgen_eltypeA; if (!tblgen_eltypeA) return emitError(loc, "'nvvm.wmma.mma' op requires attribute 'eltypeA'"); auto tblgen_eltypeB = getProperties().eltypeB; (void)tblgen_eltypeB; if (!tblgen_eltypeB) return emitError(loc, "'nvvm.wmma.mma' op requires attribute 'eltypeB'"); auto tblgen_k = getProperties().k; (void)tblgen_k; if (!tblgen_k) return emitError(loc, "'nvvm.wmma.mma' op requires attribute 'k'"); auto tblgen_layoutA = getProperties().layoutA; (void)tblgen_layoutA; if (!tblgen_layoutA) return emitError(loc, "'nvvm.wmma.mma' op requires attribute 'layoutA'"); auto tblgen_layoutB = getProperties().layoutB; (void)tblgen_layoutB; if (!tblgen_layoutB) return emitError(loc, "'nvvm.wmma.mma' op requires attribute 'layoutB'"); auto tblgen_m = getProperties().m; (void)tblgen_m; if (!tblgen_m) return emitError(loc, "'nvvm.wmma.mma' op requires attribute 'm'"); auto tblgen_n = getProperties().n; (void)tblgen_n; if (!tblgen_n) return emitError(loc, "'nvvm.wmma.mma' op requires attribute 'n'"); if (tblgen_m && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_m))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_m).getType().isSignlessInteger(32))))) return emitError(loc, "'nvvm.wmma.mma' op attribute 'm' failed to satisfy constraint: 32-bit signless integer attribute"); if (tblgen_n && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_n))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_n).getType().isSignlessInteger(32))))) return emitError(loc, "'nvvm.wmma.mma' op attribute 'n' failed to satisfy constraint: 32-bit signless integer attribute"); if (tblgen_k && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_k))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_k).getType().isSignlessInteger(32))))) return emitError(loc, "'nvvm.wmma.mma' op attribute 'k' failed to satisfy constraint: 32-bit signless integer attribute"); if (tblgen_layoutA && !((::llvm::isa<::mlir::NVVM::MMALayoutAttr>(tblgen_layoutA)))) return emitError(loc, "'nvvm.wmma.mma' op attribute 'layoutA' failed to satisfy constraint: NVVM MMA layout"); if (tblgen_layoutB && !((::llvm::isa<::mlir::NVVM::MMALayoutAttr>(tblgen_layoutB)))) return emitError(loc, "'nvvm.wmma.mma' op attribute 'layoutB' failed to satisfy constraint: NVVM MMA layout"); if (tblgen_eltypeA && !((::llvm::isa<::mlir::NVVM::MMATypesAttr>(tblgen_eltypeA)))) return emitError(loc, "'nvvm.wmma.mma' op attribute 'eltypeA' failed to satisfy constraint: NVVM MMA types"); if (tblgen_eltypeB && !((::llvm::isa<::mlir::NVVM::MMATypesAttr>(tblgen_eltypeB)))) return emitError(loc, "'nvvm.wmma.mma' op attribute 'eltypeB' failed to satisfy constraint: NVVM MMA types"); return ::mlir::success(); } std::pair WMMAMmaOp::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 WMMAMmaOp::getArgsMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult WMMAMmaOp::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.eltypeA; auto attr = dict.get("eltypeA"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `eltypeA` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.eltypeB; auto attr = dict.get("eltypeB"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `eltypeB` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.k; auto attr = dict.get("k"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `k` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.layoutA; auto attr = dict.get("layoutA"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `layoutA` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.layoutB; auto attr = dict.get("layoutB"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `layoutB` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.m; auto attr = dict.get("m"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `m` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.n; auto attr = dict.get("n"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `n` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute WMMAMmaOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.eltypeA; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("eltypeA", propStorage)); } { const auto &propStorage = prop.eltypeB; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("eltypeB", propStorage)); } { const auto &propStorage = prop.k; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("k", propStorage)); } { const auto &propStorage = prop.layoutA; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("layoutA", propStorage)); } { const auto &propStorage = prop.layoutB; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("layoutB", propStorage)); } { const auto &propStorage = prop.m; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("m", propStorage)); } { const auto &propStorage = prop.n; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("n", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code WMMAMmaOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.eltypeA.getAsOpaquePointer()), llvm::hash_value(prop.eltypeB.getAsOpaquePointer()), llvm::hash_value(prop.k.getAsOpaquePointer()), llvm::hash_value(prop.layoutA.getAsOpaquePointer()), llvm::hash_value(prop.layoutB.getAsOpaquePointer()), llvm::hash_value(prop.m.getAsOpaquePointer()), llvm::hash_value(prop.n.getAsOpaquePointer())); } std::optional WMMAMmaOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "eltypeA") return prop.eltypeA; if (name == "eltypeB") return prop.eltypeB; if (name == "k") return prop.k; if (name == "layoutA") return prop.layoutA; if (name == "layoutB") return prop.layoutB; if (name == "m") return prop.m; if (name == "n") return prop.n; return std::nullopt; } void WMMAMmaOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "eltypeA") { prop.eltypeA = ::llvm::dyn_cast_or_null>(value); return; } if (name == "eltypeB") { prop.eltypeB = ::llvm::dyn_cast_or_null>(value); return; } if (name == "k") { prop.k = ::llvm::dyn_cast_or_null>(value); return; } if (name == "layoutA") { prop.layoutA = ::llvm::dyn_cast_or_null>(value); return; } if (name == "layoutB") { prop.layoutB = ::llvm::dyn_cast_or_null>(value); return; } if (name == "m") { prop.m = ::llvm::dyn_cast_or_null>(value); return; } if (name == "n") { prop.n = ::llvm::dyn_cast_or_null>(value); return; } } void WMMAMmaOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.eltypeA) attrs.append("eltypeA", prop.eltypeA); if (prop.eltypeB) attrs.append("eltypeB", prop.eltypeB); if (prop.k) attrs.append("k", prop.k); if (prop.layoutA) attrs.append("layoutA", prop.layoutA); if (prop.layoutB) attrs.append("layoutB", prop.layoutB); if (prop.m) attrs.append("m", prop.m); if (prop.n) attrs.append("n", prop.n); } ::llvm::LogicalResult WMMAMmaOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getEltypeAAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(attr, "eltypeA", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getEltypeBAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(attr, "eltypeB", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getKAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(attr, "k", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getLayoutAAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(attr, "layoutA", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getLayoutBAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(attr, "layoutB", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getMAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(attr, "m", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(attr, "n", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult WMMAMmaOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.eltypeA))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.eltypeB))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.k))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.layoutA))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.layoutB))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.m))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.n))) return ::mlir::failure(); return ::mlir::success(); } void WMMAMmaOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.eltypeA); writer.writeAttribute(prop.eltypeB); writer.writeAttribute(prop.k); writer.writeAttribute(prop.layoutA); writer.writeAttribute(prop.layoutB); writer.writeAttribute(prop.m); writer.writeAttribute(prop.n); } uint32_t WMMAMmaOp::getM() { auto attr = getMAttr(); return attr.getValue().getZExtValue(); } uint32_t WMMAMmaOp::getN() { auto attr = getNAttr(); return attr.getValue().getZExtValue(); } uint32_t WMMAMmaOp::getK() { auto attr = getKAttr(); return attr.getValue().getZExtValue(); } ::mlir::NVVM::MMALayout WMMAMmaOp::getLayoutA() { auto attr = getLayoutAAttr(); return attr.getValue(); } ::mlir::NVVM::MMALayout WMMAMmaOp::getLayoutB() { auto attr = getLayoutBAttr(); return attr.getValue(); } ::mlir::NVVM::MMATypes WMMAMmaOp::getEltypeA() { auto attr = getEltypeAAttr(); return attr.getValue(); } ::mlir::NVVM::MMATypes WMMAMmaOp::getEltypeB() { auto attr = getEltypeBAttr(); return attr.getValue(); } void WMMAMmaOp::setM(uint32_t attrValue) { getProperties().m = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); } void WMMAMmaOp::setN(uint32_t attrValue) { getProperties().n = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); } void WMMAMmaOp::setK(uint32_t attrValue) { getProperties().k = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); } void WMMAMmaOp::setLayoutA(::mlir::NVVM::MMALayout attrValue) { getProperties().layoutA = ::mlir::NVVM::MMALayoutAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WMMAMmaOp::setLayoutB(::mlir::NVVM::MMALayout attrValue) { getProperties().layoutB = ::mlir::NVVM::MMALayoutAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WMMAMmaOp::setEltypeA(::mlir::NVVM::MMATypes attrValue) { getProperties().eltypeA = ::mlir::NVVM::MMATypesAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WMMAMmaOp::setEltypeB(::mlir::NVVM::MMATypes attrValue) { getProperties().eltypeB = ::mlir::NVVM::MMATypesAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WMMAMmaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, ::mlir::NVVM::MMATypesAttr eltypeA, ::mlir::NVVM::MMATypesAttr eltypeB, ::mlir::ValueRange args) { odsState.addOperands(args); odsState.getOrAddProperties().m = m; odsState.getOrAddProperties().n = n; odsState.getOrAddProperties().k = k; odsState.getOrAddProperties().layoutA = layoutA; odsState.getOrAddProperties().layoutB = layoutB; odsState.getOrAddProperties().eltypeA = eltypeA; odsState.getOrAddProperties().eltypeB = eltypeB; odsState.addTypes(res); } WMMAMmaOp WMMAMmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, ::mlir::NVVM::MMATypesAttr eltypeA, ::mlir::NVVM::MMATypesAttr eltypeB, ::mlir::ValueRange args) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(m), std::forward(n), std::forward(k), std::forward(layoutA), std::forward(layoutB), std::forward(eltypeA), std::forward(eltypeB), std::forward(args)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMAMmaOp WMMAMmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, ::mlir::NVVM::MMATypesAttr eltypeA, ::mlir::NVVM::MMATypesAttr eltypeB, ::mlir::ValueRange args) { return create(builder, builder.getLoc(), std::forward(res), std::forward(m), std::forward(n), std::forward(k), std::forward(layoutA), std::forward(layoutB), std::forward(eltypeA), std::forward(eltypeB), std::forward(args)); } void WMMAMmaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, ::mlir::NVVM::MMATypesAttr eltypeA, ::mlir::NVVM::MMATypesAttr eltypeB, ::mlir::ValueRange args) { odsState.addOperands(args); odsState.getOrAddProperties().m = m; odsState.getOrAddProperties().n = n; odsState.getOrAddProperties().k = k; odsState.getOrAddProperties().layoutA = layoutA; odsState.getOrAddProperties().layoutB = layoutB; odsState.getOrAddProperties().eltypeA = eltypeA; odsState.getOrAddProperties().eltypeB = eltypeB; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } WMMAMmaOp WMMAMmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, ::mlir::NVVM::MMATypesAttr eltypeA, ::mlir::NVVM::MMATypesAttr eltypeB, ::mlir::ValueRange args) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(m), std::forward(n), std::forward(k), std::forward(layoutA), std::forward(layoutB), std::forward(eltypeA), std::forward(eltypeB), std::forward(args)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMAMmaOp WMMAMmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, ::mlir::NVVM::MMATypesAttr eltypeA, ::mlir::NVVM::MMATypesAttr eltypeB, ::mlir::ValueRange args) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(m), std::forward(n), std::forward(k), std::forward(layoutA), std::forward(layoutB), std::forward(eltypeA), std::forward(eltypeB), std::forward(args)); } void WMMAMmaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, ::mlir::NVVM::MMATypes eltypeA, ::mlir::NVVM::MMATypes eltypeB, ::mlir::ValueRange args) { odsState.addOperands(args); odsState.getOrAddProperties().m = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), m); odsState.getOrAddProperties().n = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), n); odsState.getOrAddProperties().k = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), k); odsState.getOrAddProperties().layoutA = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layoutA); odsState.getOrAddProperties().layoutB = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layoutB); odsState.getOrAddProperties().eltypeA = ::mlir::NVVM::MMATypesAttr::get(odsBuilder.getContext(), eltypeA); odsState.getOrAddProperties().eltypeB = ::mlir::NVVM::MMATypesAttr::get(odsBuilder.getContext(), eltypeB); odsState.addTypes(res); } WMMAMmaOp WMMAMmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, ::mlir::NVVM::MMATypes eltypeA, ::mlir::NVVM::MMATypes eltypeB, ::mlir::ValueRange args) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(m), std::forward(n), std::forward(k), std::forward(layoutA), std::forward(layoutB), std::forward(eltypeA), std::forward(eltypeB), std::forward(args)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMAMmaOp WMMAMmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, ::mlir::NVVM::MMATypes eltypeA, ::mlir::NVVM::MMATypes eltypeB, ::mlir::ValueRange args) { return create(builder, builder.getLoc(), std::forward(res), std::forward(m), std::forward(n), std::forward(k), std::forward(layoutA), std::forward(layoutB), std::forward(eltypeA), std::forward(eltypeB), std::forward(args)); } void WMMAMmaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, ::mlir::NVVM::MMATypes eltypeA, ::mlir::NVVM::MMATypes eltypeB, ::mlir::ValueRange args) { odsState.addOperands(args); odsState.getOrAddProperties().m = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), m); odsState.getOrAddProperties().n = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), n); odsState.getOrAddProperties().k = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), k); odsState.getOrAddProperties().layoutA = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layoutA); odsState.getOrAddProperties().layoutB = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layoutB); odsState.getOrAddProperties().eltypeA = ::mlir::NVVM::MMATypesAttr::get(odsBuilder.getContext(), eltypeA); odsState.getOrAddProperties().eltypeB = ::mlir::NVVM::MMATypesAttr::get(odsBuilder.getContext(), eltypeB); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } WMMAMmaOp WMMAMmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, ::mlir::NVVM::MMATypes eltypeA, ::mlir::NVVM::MMATypes eltypeB, ::mlir::ValueRange args) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(m), std::forward(n), std::forward(k), std::forward(layoutA), std::forward(layoutB), std::forward(eltypeA), std::forward(eltypeB), std::forward(args)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMAMmaOp WMMAMmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, ::mlir::NVVM::MMATypes eltypeA, ::mlir::NVVM::MMATypes eltypeB, ::mlir::ValueRange args) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(m), std::forward(n), std::forward(k), std::forward(layoutA), std::forward(layoutB), std::forward(eltypeA), std::forward(eltypeB), std::forward(args)); } void WMMAMmaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } WMMAMmaOp WMMAMmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMAMmaOp WMMAMmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void WMMAMmaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } WMMAMmaOp WMMAMmaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMAMmaOp WMMAMmaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult WMMAMmaOp::verifyInvariantsImpl() { auto tblgen_eltypeA = getProperties().eltypeA; (void)tblgen_eltypeA; if (!tblgen_eltypeA) return emitOpError("requires attribute 'eltypeA'"); auto tblgen_eltypeB = getProperties().eltypeB; (void)tblgen_eltypeB; if (!tblgen_eltypeB) return emitOpError("requires attribute 'eltypeB'"); auto tblgen_k = getProperties().k; (void)tblgen_k; if (!tblgen_k) return emitOpError("requires attribute 'k'"); auto tblgen_layoutA = getProperties().layoutA; (void)tblgen_layoutA; if (!tblgen_layoutA) return emitOpError("requires attribute 'layoutA'"); auto tblgen_layoutB = getProperties().layoutB; (void)tblgen_layoutB; if (!tblgen_layoutB) return emitOpError("requires attribute 'layoutB'"); auto tblgen_m = getProperties().m; (void)tblgen_m; if (!tblgen_m) return emitOpError("requires attribute 'm'"); auto tblgen_n = getProperties().n; (void)tblgen_n; if (!tblgen_n) return emitOpError("requires attribute 'n'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(*this, tblgen_m, "m"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(*this, tblgen_n, "n"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(*this, tblgen_k, "k"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(*this, tblgen_layoutA, "layoutA"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(*this, tblgen_layoutB, "layoutB"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(*this, tblgen_eltypeA, "eltypeA"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(*this, tblgen_eltypeB, "eltypeB"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps34(*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_NVVMOps35(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult WMMAMmaOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult WMMAMmaOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> argsOperands; ::llvm::SMLoc argsOperandsLoc; (void)argsOperandsLoc; ::llvm::ArrayRef<::mlir::Type> argsTypes; ::llvm::ArrayRef<::mlir::Type> resTypes; argsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(argsOperands)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); ::mlir::FunctionType args__res_functionType; if (parser.parseType(args__res_functionType)) return ::mlir::failure(); argsTypes = args__res_functionType.getInputs(); resTypes = args__res_functionType.getResults(); result.addTypes(resTypes); if (parser.resolveOperands(argsOperands, argsTypes, argsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void WMMAMmaOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getArgs(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter.printFunctionalType(getArgs().getTypes(), ::llvm::ArrayRef<::mlir::Type>(getRes().getType())); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::WMMAMmaOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::WMMAMmaOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::WMMAStoreOp definitions //===----------------------------------------------------------------------===// namespace detail { WMMAStoreOpGenericAdaptorBase::WMMAStoreOpGenericAdaptorBase(WMMAStoreOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair WMMAStoreOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true, false}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } uint32_t WMMAStoreOpGenericAdaptorBase::getM() { auto attr = getMAttr(); return attr.getValue().getZExtValue(); } uint32_t WMMAStoreOpGenericAdaptorBase::getN() { auto attr = getNAttr(); return attr.getValue().getZExtValue(); } uint32_t WMMAStoreOpGenericAdaptorBase::getK() { auto attr = getKAttr(); return attr.getValue().getZExtValue(); } ::mlir::NVVM::MMALayout WMMAStoreOpGenericAdaptorBase::getLayout() { auto attr = getLayoutAttr(); return attr.getValue(); } ::mlir::NVVM::MMATypes WMMAStoreOpGenericAdaptorBase::getEltype() { auto attr = getEltypeAttr(); return attr.getValue(); } } // namespace detail WMMAStoreOpAdaptor::WMMAStoreOpAdaptor(WMMAStoreOp op) : WMMAStoreOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult WMMAStoreOpAdaptor::verify(::mlir::Location loc) { auto tblgen_eltype = getProperties().eltype; (void)tblgen_eltype; if (!tblgen_eltype) return emitError(loc, "'nvvm.wmma.store' op requires attribute 'eltype'"); auto tblgen_k = getProperties().k; (void)tblgen_k; if (!tblgen_k) return emitError(loc, "'nvvm.wmma.store' op requires attribute 'k'"); auto tblgen_layout = getProperties().layout; (void)tblgen_layout; if (!tblgen_layout) return emitError(loc, "'nvvm.wmma.store' op requires attribute 'layout'"); auto tblgen_m = getProperties().m; (void)tblgen_m; if (!tblgen_m) return emitError(loc, "'nvvm.wmma.store' op requires attribute 'm'"); auto tblgen_n = getProperties().n; (void)tblgen_n; if (!tblgen_n) return emitError(loc, "'nvvm.wmma.store' op requires attribute 'n'"); if (tblgen_m && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_m))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_m).getType().isSignlessInteger(32))))) return emitError(loc, "'nvvm.wmma.store' op attribute 'm' failed to satisfy constraint: 32-bit signless integer attribute"); if (tblgen_n && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_n))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_n).getType().isSignlessInteger(32))))) return emitError(loc, "'nvvm.wmma.store' op attribute 'n' failed to satisfy constraint: 32-bit signless integer attribute"); if (tblgen_k && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_k))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_k).getType().isSignlessInteger(32))))) return emitError(loc, "'nvvm.wmma.store' op attribute 'k' failed to satisfy constraint: 32-bit signless integer attribute"); if (tblgen_layout && !((::llvm::isa<::mlir::NVVM::MMALayoutAttr>(tblgen_layout)))) return emitError(loc, "'nvvm.wmma.store' op attribute 'layout' failed to satisfy constraint: NVVM MMA layout"); if (tblgen_eltype && !((::llvm::isa<::mlir::NVVM::MMATypesAttr>(tblgen_eltype)))) return emitError(loc, "'nvvm.wmma.store' op attribute 'eltype' failed to satisfy constraint: NVVM MMA types"); return ::mlir::success(); } std::pair WMMAStoreOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, true, false}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange WMMAStoreOp::getArgsMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult WMMAStoreOp::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.eltype; auto attr = dict.get("eltype"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `eltype` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.k; auto attr = dict.get("k"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `k` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.layout; auto attr = dict.get("layout"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `layout` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.m; auto attr = dict.get("m"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `m` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.n; auto attr = dict.get("n"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `n` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute WMMAStoreOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.eltype; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("eltype", propStorage)); } { const auto &propStorage = prop.k; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("k", propStorage)); } { const auto &propStorage = prop.layout; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("layout", propStorage)); } { const auto &propStorage = prop.m; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("m", propStorage)); } { const auto &propStorage = prop.n; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("n", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code WMMAStoreOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.eltype.getAsOpaquePointer()), llvm::hash_value(prop.k.getAsOpaquePointer()), llvm::hash_value(prop.layout.getAsOpaquePointer()), llvm::hash_value(prop.m.getAsOpaquePointer()), llvm::hash_value(prop.n.getAsOpaquePointer())); } std::optional WMMAStoreOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "eltype") return prop.eltype; if (name == "k") return prop.k; if (name == "layout") return prop.layout; if (name == "m") return prop.m; if (name == "n") return prop.n; return std::nullopt; } void WMMAStoreOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "eltype") { prop.eltype = ::llvm::dyn_cast_or_null>(value); return; } if (name == "k") { prop.k = ::llvm::dyn_cast_or_null>(value); return; } if (name == "layout") { prop.layout = ::llvm::dyn_cast_or_null>(value); return; } if (name == "m") { prop.m = ::llvm::dyn_cast_or_null>(value); return; } if (name == "n") { prop.n = ::llvm::dyn_cast_or_null>(value); return; } } void WMMAStoreOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.eltype) attrs.append("eltype", prop.eltype); if (prop.k) attrs.append("k", prop.k); if (prop.layout) attrs.append("layout", prop.layout); if (prop.m) attrs.append("m", prop.m); if (prop.n) attrs.append("n", prop.n); } ::llvm::LogicalResult WMMAStoreOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getEltypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(attr, "eltype", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getKAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(attr, "k", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getLayoutAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(attr, "layout", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getMAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(attr, "m", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(attr, "n", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult WMMAStoreOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.eltype))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.k))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.layout))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.m))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.n))) return ::mlir::failure(); return ::mlir::success(); } void WMMAStoreOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.eltype); writer.writeAttribute(prop.k); writer.writeAttribute(prop.layout); writer.writeAttribute(prop.m); writer.writeAttribute(prop.n); } uint32_t WMMAStoreOp::getM() { auto attr = getMAttr(); return attr.getValue().getZExtValue(); } uint32_t WMMAStoreOp::getN() { auto attr = getNAttr(); return attr.getValue().getZExtValue(); } uint32_t WMMAStoreOp::getK() { auto attr = getKAttr(); return attr.getValue().getZExtValue(); } ::mlir::NVVM::MMALayout WMMAStoreOp::getLayout() { auto attr = getLayoutAttr(); return attr.getValue(); } ::mlir::NVVM::MMATypes WMMAStoreOp::getEltype() { auto attr = getEltypeAttr(); return attr.getValue(); } void WMMAStoreOp::setM(uint32_t attrValue) { getProperties().m = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); } void WMMAStoreOp::setN(uint32_t attrValue) { getProperties().n = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); } void WMMAStoreOp::setK(uint32_t attrValue) { getProperties().k = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); } void WMMAStoreOp::setLayout(::mlir::NVVM::MMALayout attrValue) { getProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WMMAStoreOp::setEltype(::mlir::NVVM::MMATypes attrValue) { getProperties().eltype = ::mlir::NVVM::MMATypesAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WMMAStoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value ptr, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::MMATypesAttr eltype, ::mlir::ValueRange args, ::mlir::Value stride) { odsState.addOperands(ptr); odsState.addOperands(args); odsState.addOperands(stride); odsState.getOrAddProperties().m = m; odsState.getOrAddProperties().n = n; odsState.getOrAddProperties().k = k; odsState.getOrAddProperties().layout = layout; odsState.getOrAddProperties().eltype = eltype; } WMMAStoreOp WMMAStoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value ptr, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::MMATypesAttr eltype, ::mlir::ValueRange args, ::mlir::Value stride) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(ptr), std::forward(m), std::forward(n), std::forward(k), std::forward(layout), std::forward(eltype), std::forward(args), std::forward(stride)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMAStoreOp WMMAStoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value ptr, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::MMATypesAttr eltype, ::mlir::ValueRange args, ::mlir::Value stride) { return create(builder, builder.getLoc(), std::forward(ptr), std::forward(m), std::forward(n), std::forward(k), std::forward(layout), std::forward(eltype), std::forward(args), std::forward(stride)); } void WMMAStoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::MMATypesAttr eltype, ::mlir::ValueRange args, ::mlir::Value stride) { odsState.addOperands(ptr); odsState.addOperands(args); odsState.addOperands(stride); odsState.getOrAddProperties().m = m; odsState.getOrAddProperties().n = n; odsState.getOrAddProperties().k = k; odsState.getOrAddProperties().layout = layout; odsState.getOrAddProperties().eltype = eltype; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } WMMAStoreOp WMMAStoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::MMATypesAttr eltype, ::mlir::ValueRange args, ::mlir::Value stride) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ptr), std::forward(m), std::forward(n), std::forward(k), std::forward(layout), std::forward(eltype), std::forward(args), std::forward(stride)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMAStoreOp WMMAStoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, ::mlir::IntegerAttr m, ::mlir::IntegerAttr n, ::mlir::IntegerAttr k, ::mlir::NVVM::MMALayoutAttr layout, ::mlir::NVVM::MMATypesAttr eltype, ::mlir::ValueRange args, ::mlir::Value stride) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ptr), std::forward(m), std::forward(n), std::forward(k), std::forward(layout), std::forward(eltype), std::forward(args), std::forward(stride)); } void WMMAStoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value ptr, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::MMATypes eltype, ::mlir::ValueRange args, ::mlir::Value stride) { odsState.addOperands(ptr); odsState.addOperands(args); odsState.addOperands(stride); odsState.getOrAddProperties().m = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), m); odsState.getOrAddProperties().n = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), n); odsState.getOrAddProperties().k = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), k); odsState.getOrAddProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layout); odsState.getOrAddProperties().eltype = ::mlir::NVVM::MMATypesAttr::get(odsBuilder.getContext(), eltype); } WMMAStoreOp WMMAStoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value ptr, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::MMATypes eltype, ::mlir::ValueRange args, ::mlir::Value stride) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(ptr), std::forward(m), std::forward(n), std::forward(k), std::forward(layout), std::forward(eltype), std::forward(args), std::forward(stride)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMAStoreOp WMMAStoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value ptr, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::MMATypes eltype, ::mlir::ValueRange args, ::mlir::Value stride) { return create(builder, builder.getLoc(), std::forward(ptr), std::forward(m), std::forward(n), std::forward(k), std::forward(layout), std::forward(eltype), std::forward(args), std::forward(stride)); } void WMMAStoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::MMATypes eltype, ::mlir::ValueRange args, ::mlir::Value stride) { odsState.addOperands(ptr); odsState.addOperands(args); odsState.addOperands(stride); odsState.getOrAddProperties().m = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), m); odsState.getOrAddProperties().n = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), n); odsState.getOrAddProperties().k = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), k); odsState.getOrAddProperties().layout = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layout); odsState.getOrAddProperties().eltype = ::mlir::NVVM::MMATypesAttr::get(odsBuilder.getContext(), eltype); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } WMMAStoreOp WMMAStoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::MMATypes eltype, ::mlir::ValueRange args, ::mlir::Value stride) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ptr), std::forward(m), std::forward(n), std::forward(k), std::forward(layout), std::forward(eltype), std::forward(args), std::forward(stride)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMAStoreOp WMMAStoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value ptr, uint32_t m, uint32_t n, uint32_t k, ::mlir::NVVM::MMALayout layout, ::mlir::NVVM::MMATypes eltype, ::mlir::ValueRange args, ::mlir::Value stride) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ptr), std::forward(m), std::forward(n), std::forward(k), std::forward(layout), std::forward(eltype), std::forward(args), std::forward(stride)); } void WMMAStoreOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } WMMAStoreOp WMMAStoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMAStoreOp WMMAStoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void WMMAStoreOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } WMMAStoreOp WMMAStoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WMMAStoreOp WMMAStoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult WMMAStoreOp::verifyInvariantsImpl() { auto tblgen_eltype = getProperties().eltype; (void)tblgen_eltype; if (!tblgen_eltype) return emitOpError("requires attribute 'eltype'"); auto tblgen_k = getProperties().k; (void)tblgen_k; if (!tblgen_k) return emitOpError("requires attribute 'k'"); auto tblgen_layout = getProperties().layout; (void)tblgen_layout; if (!tblgen_layout) return emitOpError("requires attribute 'layout'"); auto tblgen_m = getProperties().m; (void)tblgen_m; if (!tblgen_m) return emitOpError("requires attribute 'm'"); auto tblgen_n = getProperties().n; (void)tblgen_n; if (!tblgen_n) return emitOpError("requires attribute 'n'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(*this, tblgen_m, "m"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(*this, tblgen_n, "n"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps24(*this, tblgen_k, "k"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(*this, tblgen_layout, "layout"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps39(*this, tblgen_eltype, "eltype"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps24(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps34(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult WMMAStoreOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult WMMAStoreOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand ptrRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> ptrOperands(&ptrRawOperand, 1); ::llvm::SMLoc ptrOperandsLoc; (void)ptrOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand strideRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> strideOperands(&strideRawOperand, 1); ::llvm::SMLoc strideOperandsLoc; (void)strideOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> argsOperands; ::llvm::SMLoc argsOperandsLoc; (void)argsOperandsLoc; ::mlir::Type ptrRawType{}; ::llvm::ArrayRef<::mlir::Type> ptrTypes(&ptrRawType, 1); ::llvm::SmallVector<::mlir::Type, 1> argsTypes; ptrOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(ptrRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); strideOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(strideRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); argsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(argsOperands)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseType(ptrRawType)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); if (parser.parseTypeList(argsTypes)) return ::mlir::failure(); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); if (parser.resolveOperands(ptrOperands, ptrTypes, ptrOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(argsOperands, argsTypes, argsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(strideOperands, odsBuildableType0, strideOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void WMMAStoreOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getPtr(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getStride(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getArgs(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getPtr().getType(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getArgs().getTypes(); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::WMMAStoreOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::WMMAStoreOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::WarpDimOp definitions //===----------------------------------------------------------------------===// namespace detail { WarpDimOpGenericAdaptorBase::WarpDimOpGenericAdaptorBase(WarpDimOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> WarpDimOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail WarpDimOpAdaptor::WarpDimOpAdaptor(WarpDimOp op) : WarpDimOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult WarpDimOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.nwarpid' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult WarpDimOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute WarpDimOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code WarpDimOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional WarpDimOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void WarpDimOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void WarpDimOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult WarpDimOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult WarpDimOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void WarpDimOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> WarpDimOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void WarpDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } WarpDimOp WarpDimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpDimOp WarpDimOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void WarpDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } WarpDimOp WarpDimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpDimOp WarpDimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void WarpDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(WarpDimOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } WarpDimOp WarpDimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpDimOp WarpDimOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void WarpDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } WarpDimOp WarpDimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpDimOp WarpDimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void WarpDimOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } WarpDimOp WarpDimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpDimOp WarpDimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void WarpDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(WarpDimOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } WarpDimOp WarpDimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpDimOp WarpDimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void WarpDimOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } WarpDimOp WarpDimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpDimOp WarpDimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void WarpDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(WarpDimOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } WarpDimOp WarpDimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpDimOp WarpDimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult WarpDimOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult WarpDimOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult WarpDimOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult WarpDimOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void WarpDimOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void WarpDimOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void WarpDimOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult WarpDimOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::WarpDimOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::WarpDimOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::WarpIdOp definitions //===----------------------------------------------------------------------===// namespace detail { WarpIdOpGenericAdaptorBase::WarpIdOpGenericAdaptorBase(WarpIdOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> WarpIdOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail WarpIdOpAdaptor::WarpIdOpAdaptor(WarpIdOp op) : WarpIdOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult WarpIdOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.warpid' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult WarpIdOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute WarpIdOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code WarpIdOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional WarpIdOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void WarpIdOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void WarpIdOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult WarpIdOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult WarpIdOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void WarpIdOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> WarpIdOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void WarpIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } WarpIdOp WarpIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpIdOp WarpIdOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void WarpIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } WarpIdOp WarpIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpIdOp WarpIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void WarpIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(WarpIdOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } WarpIdOp WarpIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpIdOp WarpIdOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void WarpIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } WarpIdOp WarpIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpIdOp WarpIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void WarpIdOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } WarpIdOp WarpIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpIdOp WarpIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void WarpIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(WarpIdOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } WarpIdOp WarpIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpIdOp WarpIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void WarpIdOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } WarpIdOp WarpIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpIdOp WarpIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void WarpIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(WarpIdOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } WarpIdOp WarpIdOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpIdOp WarpIdOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult WarpIdOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult WarpIdOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult WarpIdOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult WarpIdOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void WarpIdOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void WarpIdOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void WarpIdOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult WarpIdOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::WarpIdOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::WarpIdOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::WarpSizeOp definitions //===----------------------------------------------------------------------===// namespace detail { WarpSizeOpGenericAdaptorBase::WarpSizeOpGenericAdaptorBase(WarpSizeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::LLVM::ConstantRangeAttr> WarpSizeOpGenericAdaptorBase::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } } // namespace detail WarpSizeOpAdaptor::WarpSizeOpAdaptor(WarpSizeOp op) : WarpSizeOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult WarpSizeOpAdaptor::verify(::mlir::Location loc) { auto tblgen_range = getProperties().range; (void)tblgen_range; if (tblgen_range && !((::llvm::isa<::mlir::LLVM::ConstantRangeAttr>(tblgen_range)))) return emitError(loc, "'nvvm.read.ptx.sreg.warpsize' op attribute 'range' failed to satisfy constraint: A range of two integers, corresponding to LLVM's ConstantRange"); return ::mlir::success(); } ::llvm::LogicalResult WarpSizeOp::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.range; auto attr = dict.get("range"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `range` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute WarpSizeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.range; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("range", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code WarpSizeOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.range.getAsOpaquePointer())); } std::optional WarpSizeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "range") return prop.range; return std::nullopt; } void WarpSizeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "range") { prop.range = ::llvm::dyn_cast_or_null>(value); return; } } void WarpSizeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.range) attrs.append("range", prop.range); } ::llvm::LogicalResult WarpSizeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getRangeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(attr, "range", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult WarpSizeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.range))) return ::mlir::failure(); return ::mlir::success(); } void WarpSizeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.range); } ::std::optional<::mlir::LLVM::ConstantRangeAttr> WarpSizeOp::getRange() { auto attr = getRangeAttr(); return attr ? ::std::optional<::mlir::LLVM::ConstantRangeAttr>(::llvm::cast<::mlir::LLVM::ConstantRangeAttr>(attr)) : (::std::nullopt); } void WarpSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType) { build(odsBuilder, odsState, resultType, ::mlir::LLVM::ConstantRangeAttr{}); } WarpSizeOp WarpSizeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpSizeOp WarpSizeOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType) { return create(builder, builder.getLoc(), std::forward(resultType)); } void WarpSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } odsState.addTypes(res); } WarpSizeOp WarpSizeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(res), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpSizeOp WarpSizeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type res, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(res), std::forward(range)); } void WarpSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(WarpSizeOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } WarpSizeOp WarpSizeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpSizeOp WarpSizeOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(range)); } void WarpSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { if (range) { odsState.getOrAddProperties().range = range; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } WarpSizeOp WarpSizeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(range)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpSizeOp WarpSizeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::LLVM::ConstantRangeAttr range) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(range)); } void WarpSizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } WarpSizeOp WarpSizeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpSizeOp WarpSizeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void WarpSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(WarpSizeOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } WarpSizeOp WarpSizeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpSizeOp WarpSizeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void WarpSizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } WarpSizeOp WarpSizeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpSizeOp WarpSizeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void WarpSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(WarpSizeOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } WarpSizeOp WarpSizeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WarpSizeOp WarpSizeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult WarpSizeOp::verifyInvariantsImpl() { auto tblgen_range = getProperties().range; (void)tblgen_range; if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps5(*this, tblgen_range, "range"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult WarpSizeOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult WarpSizeOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(32); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult WarpSizeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::LLVM::ConstantRangeAttr rangeAttr; ::mlir::Type resRawType{}; ::llvm::ArrayRef<::mlir::Type> resTypes(&resRawType, 1); if (::mlir::succeeded(parser.parseOptionalKeyword("range"))) { if (parser.parseCustomAttributeWithFallback(rangeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (rangeAttr) result.getOrAddProperties().range = rangeAttr; } { 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(); resRawType = type; } result.addTypes(resTypes); return ::mlir::success(); } void WarpSizeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getRangeAttr()) { _odsPrinter << ' ' << "range"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getRangeAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("range"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getRes().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IntegerType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void WarpSizeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } // Infer the result ranges based on the range attribute. void WarpSizeOp::inferResultRanges( ArrayRef<::mlir::ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges) { nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges); } // Verify the range attribute satisfies LLVM ConstantRange constructor requirements. ::llvm::LogicalResult WarpSizeOp::verify() { return verifyConstantRangeAttr(getOperation(), getRange()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::WarpSizeOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::WarpSizeOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::WgmmaFenceAlignedOp definitions //===----------------------------------------------------------------------===// namespace detail { WgmmaFenceAlignedOpGenericAdaptorBase::WgmmaFenceAlignedOpGenericAdaptorBase(WgmmaFenceAlignedOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail WgmmaFenceAlignedOpAdaptor::WgmmaFenceAlignedOpAdaptor(WgmmaFenceAlignedOp op) : WgmmaFenceAlignedOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult WgmmaFenceAlignedOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult WgmmaFenceAlignedOp::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 WgmmaFenceAlignedOp::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 WgmmaFenceAlignedOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional WgmmaFenceAlignedOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void WgmmaFenceAlignedOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void WgmmaFenceAlignedOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult WgmmaFenceAlignedOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void WgmmaFenceAlignedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { } WgmmaFenceAlignedOp WgmmaFenceAlignedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaFenceAlignedOp WgmmaFenceAlignedOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void WgmmaFenceAlignedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } WgmmaFenceAlignedOp WgmmaFenceAlignedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaFenceAlignedOp WgmmaFenceAlignedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void WgmmaFenceAlignedOp::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); } WgmmaFenceAlignedOp WgmmaFenceAlignedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaFenceAlignedOp WgmmaFenceAlignedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void WgmmaFenceAlignedOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } WgmmaFenceAlignedOp WgmmaFenceAlignedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaFenceAlignedOp WgmmaFenceAlignedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult WgmmaFenceAlignedOp::verifyInvariantsImpl() { return ::mlir::success(); } ::llvm::LogicalResult WgmmaFenceAlignedOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult WgmmaFenceAlignedOp::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 WgmmaFenceAlignedOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::WgmmaFenceAlignedOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::WgmmaGroupSyncAlignedOp definitions //===----------------------------------------------------------------------===// namespace detail { WgmmaGroupSyncAlignedOpGenericAdaptorBase::WgmmaGroupSyncAlignedOpGenericAdaptorBase(WgmmaGroupSyncAlignedOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail WgmmaGroupSyncAlignedOpAdaptor::WgmmaGroupSyncAlignedOpAdaptor(WgmmaGroupSyncAlignedOp op) : WgmmaGroupSyncAlignedOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult WgmmaGroupSyncAlignedOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult WgmmaGroupSyncAlignedOp::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 WgmmaGroupSyncAlignedOp::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 WgmmaGroupSyncAlignedOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional WgmmaGroupSyncAlignedOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void WgmmaGroupSyncAlignedOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void WgmmaGroupSyncAlignedOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult WgmmaGroupSyncAlignedOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void WgmmaGroupSyncAlignedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { } WgmmaGroupSyncAlignedOp WgmmaGroupSyncAlignedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaGroupSyncAlignedOp WgmmaGroupSyncAlignedOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void WgmmaGroupSyncAlignedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } WgmmaGroupSyncAlignedOp WgmmaGroupSyncAlignedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaGroupSyncAlignedOp WgmmaGroupSyncAlignedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void WgmmaGroupSyncAlignedOp::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); } WgmmaGroupSyncAlignedOp WgmmaGroupSyncAlignedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaGroupSyncAlignedOp WgmmaGroupSyncAlignedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void WgmmaGroupSyncAlignedOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } WgmmaGroupSyncAlignedOp WgmmaGroupSyncAlignedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaGroupSyncAlignedOp WgmmaGroupSyncAlignedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult WgmmaGroupSyncAlignedOp::verifyInvariantsImpl() { return ::mlir::success(); } ::llvm::LogicalResult WgmmaGroupSyncAlignedOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult WgmmaGroupSyncAlignedOp::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 WgmmaGroupSyncAlignedOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::WgmmaGroupSyncAlignedOp) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::WgmmaMmaAsyncOp definitions //===----------------------------------------------------------------------===// namespace detail { WgmmaMmaAsyncOpGenericAdaptorBase::WgmmaMmaAsyncOpGenericAdaptorBase(WgmmaMmaAsyncOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::NVVM::MMAShapeAttr WgmmaMmaAsyncOpGenericAdaptorBase::getShape() { auto attr = getShapeAttr(); return ::llvm::cast<::mlir::NVVM::MMAShapeAttr>(attr); } ::mlir::NVVM::WGMMATypes WgmmaMmaAsyncOpGenericAdaptorBase::getTypeA() { auto attr = getTypeAAttr(); return attr.getValue(); } ::mlir::NVVM::WGMMATypes WgmmaMmaAsyncOpGenericAdaptorBase::getTypeB() { auto attr = getTypeBAttr(); return attr.getValue(); } ::mlir::NVVM::WGMMATypes WgmmaMmaAsyncOpGenericAdaptorBase::getTypeD() { auto attr = getTypeDAttr(); return attr.getValue(); } ::mlir::NVVM::WGMMAScaleOut WgmmaMmaAsyncOpGenericAdaptorBase::getScaleD() { auto attr = getScaleDAttr(); return attr.getValue(); } ::mlir::NVVM::WGMMAScaleIn WgmmaMmaAsyncOpGenericAdaptorBase::getScaleA() { auto attr = getScaleAAttr(); return attr.getValue(); } ::mlir::NVVM::WGMMAScaleIn WgmmaMmaAsyncOpGenericAdaptorBase::getScaleB() { auto attr = getScaleBAttr(); return attr.getValue(); } ::mlir::NVVM::MMALayout WgmmaMmaAsyncOpGenericAdaptorBase::getLayoutA() { auto attr = getLayoutAAttr(); return attr.getValue(); } ::mlir::NVVM::MMALayout WgmmaMmaAsyncOpGenericAdaptorBase::getLayoutB() { auto attr = getLayoutBAttr(); return attr.getValue(); } ::std::optional<::mlir::NVVM::MMAIntOverflow> WgmmaMmaAsyncOpGenericAdaptorBase::getSatfinite() { auto attr = getSatfiniteAttr(); return attr ? ::std::optional<::mlir::NVVM::MMAIntOverflow>(attr.getValue()) : (::std::nullopt); } } // namespace detail WgmmaMmaAsyncOpAdaptor::WgmmaMmaAsyncOpAdaptor(WgmmaMmaAsyncOp op) : WgmmaMmaAsyncOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult WgmmaMmaAsyncOpAdaptor::verify(::mlir::Location loc) { auto tblgen_layoutA = getProperties().layoutA; (void)tblgen_layoutA; if (!tblgen_layoutA) return emitError(loc, "'nvvm.wgmma.mma_async' op requires attribute 'layoutA'"); auto tblgen_layoutB = getProperties().layoutB; (void)tblgen_layoutB; if (!tblgen_layoutB) return emitError(loc, "'nvvm.wgmma.mma_async' op requires attribute 'layoutB'"); auto tblgen_satfinite = getProperties().satfinite; (void)tblgen_satfinite; auto tblgen_scaleA = getProperties().scaleA; (void)tblgen_scaleA; if (!tblgen_scaleA) return emitError(loc, "'nvvm.wgmma.mma_async' op requires attribute 'scaleA'"); auto tblgen_scaleB = getProperties().scaleB; (void)tblgen_scaleB; if (!tblgen_scaleB) return emitError(loc, "'nvvm.wgmma.mma_async' op requires attribute 'scaleB'"); auto tblgen_scaleD = getProperties().scaleD; (void)tblgen_scaleD; if (!tblgen_scaleD) return emitError(loc, "'nvvm.wgmma.mma_async' op requires attribute 'scaleD'"); auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitError(loc, "'nvvm.wgmma.mma_async' op requires attribute 'shape'"); auto tblgen_typeA = getProperties().typeA; (void)tblgen_typeA; if (!tblgen_typeA) return emitError(loc, "'nvvm.wgmma.mma_async' op requires attribute 'typeA'"); auto tblgen_typeB = getProperties().typeB; (void)tblgen_typeB; if (!tblgen_typeB) return emitError(loc, "'nvvm.wgmma.mma_async' op requires attribute 'typeB'"); auto tblgen_typeD = getProperties().typeD; (void)tblgen_typeD; if (!tblgen_typeD) return emitError(loc, "'nvvm.wgmma.mma_async' op requires attribute 'typeD'"); if (tblgen_shape && !((::llvm::isa<::mlir::NVVM::MMAShapeAttr>(tblgen_shape)))) return emitError(loc, "'nvvm.wgmma.mma_async' op attribute 'shape' failed to satisfy constraint: Attribute for MMA operation shape."); if (tblgen_typeA && !((::llvm::isa<::mlir::NVVM::WGMMATypesAttr>(tblgen_typeA)))) return emitError(loc, "'nvvm.wgmma.mma_async' op attribute 'typeA' failed to satisfy constraint: NVVM WGMMA types"); if (tblgen_typeB && !((::llvm::isa<::mlir::NVVM::WGMMATypesAttr>(tblgen_typeB)))) return emitError(loc, "'nvvm.wgmma.mma_async' op attribute 'typeB' failed to satisfy constraint: NVVM WGMMA types"); if (tblgen_typeD && !((::llvm::isa<::mlir::NVVM::WGMMATypesAttr>(tblgen_typeD)))) return emitError(loc, "'nvvm.wgmma.mma_async' op attribute 'typeD' failed to satisfy constraint: NVVM WGMMA types"); if (tblgen_scaleD && !((::llvm::isa<::mlir::NVVM::WGMMAScaleOutAttr>(tblgen_scaleD)))) return emitError(loc, "'nvvm.wgmma.mma_async' op attribute 'scaleD' failed to satisfy constraint: WGMMA input predicate"); if (tblgen_scaleA && !((::llvm::isa<::mlir::NVVM::WGMMAScaleInAttr>(tblgen_scaleA)))) return emitError(loc, "'nvvm.wgmma.mma_async' op attribute 'scaleA' failed to satisfy constraint: WGMMA overflow options"); if (tblgen_scaleB && !((::llvm::isa<::mlir::NVVM::WGMMAScaleInAttr>(tblgen_scaleB)))) return emitError(loc, "'nvvm.wgmma.mma_async' op attribute 'scaleB' failed to satisfy constraint: WGMMA overflow options"); if (tblgen_layoutA && !((::llvm::isa<::mlir::NVVM::MMALayoutAttr>(tblgen_layoutA)))) return emitError(loc, "'nvvm.wgmma.mma_async' op attribute 'layoutA' failed to satisfy constraint: NVVM MMA layout"); if (tblgen_layoutB && !((::llvm::isa<::mlir::NVVM::MMALayoutAttr>(tblgen_layoutB)))) return emitError(loc, "'nvvm.wgmma.mma_async' op attribute 'layoutB' failed to satisfy constraint: NVVM MMA layout"); if (tblgen_satfinite && !((::llvm::isa<::mlir::NVVM::MMAIntOverflowAttr>(tblgen_satfinite)))) return emitError(loc, "'nvvm.wgmma.mma_async' op attribute 'satfinite' failed to satisfy constraint: MMA overflow options"); return ::mlir::success(); } ::llvm::LogicalResult WgmmaMmaAsyncOp::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.layoutA; auto attr = dict.get("layoutA"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `layoutA` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.layoutB; auto attr = dict.get("layoutB"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `layoutB` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.satfinite; auto attr = dict.get("satfinite"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `satfinite` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.scaleA; auto attr = dict.get("scaleA"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scaleA` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.scaleB; auto attr = dict.get("scaleB"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scaleB` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.scaleD; auto attr = dict.get("scaleD"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `scaleD` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.shape; auto attr = dict.get("shape"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `shape` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.typeA; auto attr = dict.get("typeA"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `typeA` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.typeB; auto attr = dict.get("typeB"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `typeB` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.typeD; auto attr = dict.get("typeD"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `typeD` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute WgmmaMmaAsyncOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.layoutA; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("layoutA", propStorage)); } { const auto &propStorage = prop.layoutB; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("layoutB", propStorage)); } { const auto &propStorage = prop.satfinite; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("satfinite", propStorage)); } { const auto &propStorage = prop.scaleA; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("scaleA", propStorage)); } { const auto &propStorage = prop.scaleB; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("scaleB", propStorage)); } { const auto &propStorage = prop.scaleD; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("scaleD", propStorage)); } { const auto &propStorage = prop.shape; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("shape", propStorage)); } { const auto &propStorage = prop.typeA; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("typeA", propStorage)); } { const auto &propStorage = prop.typeB; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("typeB", propStorage)); } { const auto &propStorage = prop.typeD; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("typeD", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code WgmmaMmaAsyncOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.layoutA.getAsOpaquePointer()), llvm::hash_value(prop.layoutB.getAsOpaquePointer()), llvm::hash_value(prop.satfinite.getAsOpaquePointer()), llvm::hash_value(prop.scaleA.getAsOpaquePointer()), llvm::hash_value(prop.scaleB.getAsOpaquePointer()), llvm::hash_value(prop.scaleD.getAsOpaquePointer()), llvm::hash_value(prop.shape.getAsOpaquePointer()), llvm::hash_value(prop.typeA.getAsOpaquePointer()), llvm::hash_value(prop.typeB.getAsOpaquePointer()), llvm::hash_value(prop.typeD.getAsOpaquePointer())); } std::optional WgmmaMmaAsyncOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "layoutA") return prop.layoutA; if (name == "layoutB") return prop.layoutB; if (name == "satfinite") return prop.satfinite; if (name == "scaleA") return prop.scaleA; if (name == "scaleB") return prop.scaleB; if (name == "scaleD") return prop.scaleD; if (name == "shape") return prop.shape; if (name == "typeA") return prop.typeA; if (name == "typeB") return prop.typeB; if (name == "typeD") return prop.typeD; return std::nullopt; } void WgmmaMmaAsyncOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "layoutA") { prop.layoutA = ::llvm::dyn_cast_or_null>(value); return; } if (name == "layoutB") { prop.layoutB = ::llvm::dyn_cast_or_null>(value); return; } if (name == "satfinite") { prop.satfinite = ::llvm::dyn_cast_or_null>(value); return; } if (name == "scaleA") { prop.scaleA = ::llvm::dyn_cast_or_null>(value); return; } if (name == "scaleB") { prop.scaleB = ::llvm::dyn_cast_or_null>(value); return; } if (name == "scaleD") { prop.scaleD = ::llvm::dyn_cast_or_null>(value); return; } if (name == "shape") { prop.shape = ::llvm::dyn_cast_or_null>(value); return; } if (name == "typeA") { prop.typeA = ::llvm::dyn_cast_or_null>(value); return; } if (name == "typeB") { prop.typeB = ::llvm::dyn_cast_or_null>(value); return; } if (name == "typeD") { prop.typeD = ::llvm::dyn_cast_or_null>(value); return; } } void WgmmaMmaAsyncOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.layoutA) attrs.append("layoutA", prop.layoutA); if (prop.layoutB) attrs.append("layoutB", prop.layoutB); if (prop.satfinite) attrs.append("satfinite", prop.satfinite); if (prop.scaleA) attrs.append("scaleA", prop.scaleA); if (prop.scaleB) attrs.append("scaleB", prop.scaleB); if (prop.scaleD) attrs.append("scaleD", prop.scaleD); if (prop.shape) attrs.append("shape", prop.shape); if (prop.typeA) attrs.append("typeA", prop.typeA); if (prop.typeB) attrs.append("typeB", prop.typeB); if (prop.typeD) attrs.append("typeD", prop.typeD); } ::llvm::LogicalResult WgmmaMmaAsyncOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getLayoutAAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(attr, "layoutA", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getLayoutBAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(attr, "layoutB", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSatfiniteAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps44(attr, "satfinite", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getScaleAAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps71(attr, "scaleA", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getScaleBAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps71(attr, "scaleB", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getScaleDAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps70(attr, "scaleD", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getShapeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps38(attr, "shape", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getTypeAAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps69(attr, "typeA", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getTypeBAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps69(attr, "typeB", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getTypeDAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps69(attr, "typeD", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult WgmmaMmaAsyncOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.layoutA))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.layoutB))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.satfinite))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.scaleA))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.scaleB))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.scaleD))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.shape))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.typeA))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.typeB))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.typeD))) return ::mlir::failure(); return ::mlir::success(); } void WgmmaMmaAsyncOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.layoutA); writer.writeAttribute(prop.layoutB); writer.writeOptionalAttribute(prop.satfinite); writer.writeAttribute(prop.scaleA); writer.writeAttribute(prop.scaleB); writer.writeAttribute(prop.scaleD); writer.writeAttribute(prop.shape); writer.writeAttribute(prop.typeA); writer.writeAttribute(prop.typeB); writer.writeAttribute(prop.typeD); } ::mlir::NVVM::MMAShapeAttr WgmmaMmaAsyncOp::getShape() { auto attr = getShapeAttr(); return ::llvm::cast<::mlir::NVVM::MMAShapeAttr>(attr); } ::mlir::NVVM::WGMMATypes WgmmaMmaAsyncOp::getTypeA() { auto attr = getTypeAAttr(); return attr.getValue(); } ::mlir::NVVM::WGMMATypes WgmmaMmaAsyncOp::getTypeB() { auto attr = getTypeBAttr(); return attr.getValue(); } ::mlir::NVVM::WGMMATypes WgmmaMmaAsyncOp::getTypeD() { auto attr = getTypeDAttr(); return attr.getValue(); } ::mlir::NVVM::WGMMAScaleOut WgmmaMmaAsyncOp::getScaleD() { auto attr = getScaleDAttr(); return attr.getValue(); } ::mlir::NVVM::WGMMAScaleIn WgmmaMmaAsyncOp::getScaleA() { auto attr = getScaleAAttr(); return attr.getValue(); } ::mlir::NVVM::WGMMAScaleIn WgmmaMmaAsyncOp::getScaleB() { auto attr = getScaleBAttr(); return attr.getValue(); } ::mlir::NVVM::MMALayout WgmmaMmaAsyncOp::getLayoutA() { auto attr = getLayoutAAttr(); return attr.getValue(); } ::mlir::NVVM::MMALayout WgmmaMmaAsyncOp::getLayoutB() { auto attr = getLayoutBAttr(); return attr.getValue(); } ::std::optional<::mlir::NVVM::MMAIntOverflow> WgmmaMmaAsyncOp::getSatfinite() { auto attr = getSatfiniteAttr(); return attr ? ::std::optional<::mlir::NVVM::MMAIntOverflow>(attr.getValue()) : (::std::nullopt); } void WgmmaMmaAsyncOp::setTypeA(::mlir::NVVM::WGMMATypes attrValue) { getProperties().typeA = ::mlir::NVVM::WGMMATypesAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WgmmaMmaAsyncOp::setTypeB(::mlir::NVVM::WGMMATypes attrValue) { getProperties().typeB = ::mlir::NVVM::WGMMATypesAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WgmmaMmaAsyncOp::setTypeD(::mlir::NVVM::WGMMATypes attrValue) { getProperties().typeD = ::mlir::NVVM::WGMMATypesAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WgmmaMmaAsyncOp::setScaleD(::mlir::NVVM::WGMMAScaleOut attrValue) { getProperties().scaleD = ::mlir::NVVM::WGMMAScaleOutAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WgmmaMmaAsyncOp::setScaleA(::mlir::NVVM::WGMMAScaleIn attrValue) { getProperties().scaleA = ::mlir::NVVM::WGMMAScaleInAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WgmmaMmaAsyncOp::setScaleB(::mlir::NVVM::WGMMAScaleIn attrValue) { getProperties().scaleB = ::mlir::NVVM::WGMMAScaleInAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WgmmaMmaAsyncOp::setLayoutA(::mlir::NVVM::MMALayout attrValue) { getProperties().layoutA = ::mlir::NVVM::MMALayoutAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WgmmaMmaAsyncOp::setLayoutB(::mlir::NVVM::MMALayout attrValue) { getProperties().layoutB = ::mlir::NVVM::MMALayoutAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void WgmmaMmaAsyncOp::setSatfinite(::std::optional<::mlir::NVVM::MMAIntOverflow> attrValue) { auto &odsProp = getProperties().satfinite; if (attrValue) odsProp = ::mlir::NVVM::MMAIntOverflowAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void WgmmaMmaAsyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type results, ::mlir::Value inouts, ::mlir::Value descriptorA, ::mlir::Value descriptorB, ::mlir::NVVM::MMAShapeAttr shape, ::mlir::NVVM::WGMMATypesAttr typeA, ::mlir::NVVM::WGMMATypesAttr typeB, ::mlir::NVVM::WGMMATypesAttr typeD, ::mlir::NVVM::WGMMAScaleOutAttr scaleD, ::mlir::NVVM::WGMMAScaleInAttr scaleA, ::mlir::NVVM::WGMMAScaleInAttr scaleB, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, /*optional*/::mlir::NVVM::MMAIntOverflowAttr satfinite) { odsState.addOperands(inouts); odsState.addOperands(descriptorA); odsState.addOperands(descriptorB); odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().typeA = typeA; odsState.getOrAddProperties().typeB = typeB; odsState.getOrAddProperties().typeD = typeD; odsState.getOrAddProperties().scaleD = scaleD; odsState.getOrAddProperties().scaleA = scaleA; odsState.getOrAddProperties().scaleB = scaleB; odsState.getOrAddProperties().layoutA = layoutA; odsState.getOrAddProperties().layoutB = layoutB; if (satfinite) { odsState.getOrAddProperties().satfinite = satfinite; } odsState.addTypes(results); } WgmmaMmaAsyncOp WgmmaMmaAsyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type results, ::mlir::Value inouts, ::mlir::Value descriptorA, ::mlir::Value descriptorB, ::mlir::NVVM::MMAShapeAttr shape, ::mlir::NVVM::WGMMATypesAttr typeA, ::mlir::NVVM::WGMMATypesAttr typeB, ::mlir::NVVM::WGMMATypesAttr typeD, ::mlir::NVVM::WGMMAScaleOutAttr scaleD, ::mlir::NVVM::WGMMAScaleInAttr scaleA, ::mlir::NVVM::WGMMAScaleInAttr scaleB, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, /*optional*/::mlir::NVVM::MMAIntOverflowAttr satfinite) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(results), std::forward(inouts), std::forward(descriptorA), std::forward(descriptorB), std::forward(shape), std::forward(typeA), std::forward(typeB), std::forward(typeD), std::forward(scaleD), std::forward(scaleA), std::forward(scaleB), std::forward(layoutA), std::forward(layoutB), std::forward(satfinite)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaMmaAsyncOp WgmmaMmaAsyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type results, ::mlir::Value inouts, ::mlir::Value descriptorA, ::mlir::Value descriptorB, ::mlir::NVVM::MMAShapeAttr shape, ::mlir::NVVM::WGMMATypesAttr typeA, ::mlir::NVVM::WGMMATypesAttr typeB, ::mlir::NVVM::WGMMATypesAttr typeD, ::mlir::NVVM::WGMMAScaleOutAttr scaleD, ::mlir::NVVM::WGMMAScaleInAttr scaleA, ::mlir::NVVM::WGMMAScaleInAttr scaleB, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, /*optional*/::mlir::NVVM::MMAIntOverflowAttr satfinite) { return create(builder, builder.getLoc(), std::forward(results), std::forward(inouts), std::forward(descriptorA), std::forward(descriptorB), std::forward(shape), std::forward(typeA), std::forward(typeB), std::forward(typeD), std::forward(scaleD), std::forward(scaleA), std::forward(scaleB), std::forward(layoutA), std::forward(layoutB), std::forward(satfinite)); } void WgmmaMmaAsyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value inouts, ::mlir::Value descriptorA, ::mlir::Value descriptorB, ::mlir::NVVM::MMAShapeAttr shape, ::mlir::NVVM::WGMMATypesAttr typeA, ::mlir::NVVM::WGMMATypesAttr typeB, ::mlir::NVVM::WGMMATypesAttr typeD, ::mlir::NVVM::WGMMAScaleOutAttr scaleD, ::mlir::NVVM::WGMMAScaleInAttr scaleA, ::mlir::NVVM::WGMMAScaleInAttr scaleB, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, /*optional*/::mlir::NVVM::MMAIntOverflowAttr satfinite) { odsState.addOperands(inouts); odsState.addOperands(descriptorA); odsState.addOperands(descriptorB); odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().typeA = typeA; odsState.getOrAddProperties().typeB = typeB; odsState.getOrAddProperties().typeD = typeD; odsState.getOrAddProperties().scaleD = scaleD; odsState.getOrAddProperties().scaleA = scaleA; odsState.getOrAddProperties().scaleB = scaleB; odsState.getOrAddProperties().layoutA = layoutA; odsState.getOrAddProperties().layoutB = layoutB; if (satfinite) { odsState.getOrAddProperties().satfinite = satfinite; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } WgmmaMmaAsyncOp WgmmaMmaAsyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value inouts, ::mlir::Value descriptorA, ::mlir::Value descriptorB, ::mlir::NVVM::MMAShapeAttr shape, ::mlir::NVVM::WGMMATypesAttr typeA, ::mlir::NVVM::WGMMATypesAttr typeB, ::mlir::NVVM::WGMMATypesAttr typeD, ::mlir::NVVM::WGMMAScaleOutAttr scaleD, ::mlir::NVVM::WGMMAScaleInAttr scaleA, ::mlir::NVVM::WGMMAScaleInAttr scaleB, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, /*optional*/::mlir::NVVM::MMAIntOverflowAttr satfinite) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(inouts), std::forward(descriptorA), std::forward(descriptorB), std::forward(shape), std::forward(typeA), std::forward(typeB), std::forward(typeD), std::forward(scaleD), std::forward(scaleA), std::forward(scaleB), std::forward(layoutA), std::forward(layoutB), std::forward(satfinite)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaMmaAsyncOp WgmmaMmaAsyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value inouts, ::mlir::Value descriptorA, ::mlir::Value descriptorB, ::mlir::NVVM::MMAShapeAttr shape, ::mlir::NVVM::WGMMATypesAttr typeA, ::mlir::NVVM::WGMMATypesAttr typeB, ::mlir::NVVM::WGMMATypesAttr typeD, ::mlir::NVVM::WGMMAScaleOutAttr scaleD, ::mlir::NVVM::WGMMAScaleInAttr scaleA, ::mlir::NVVM::WGMMAScaleInAttr scaleB, ::mlir::NVVM::MMALayoutAttr layoutA, ::mlir::NVVM::MMALayoutAttr layoutB, /*optional*/::mlir::NVVM::MMAIntOverflowAttr satfinite) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(inouts), std::forward(descriptorA), std::forward(descriptorB), std::forward(shape), std::forward(typeA), std::forward(typeB), std::forward(typeD), std::forward(scaleD), std::forward(scaleA), std::forward(scaleB), std::forward(layoutA), std::forward(layoutB), std::forward(satfinite)); } void WgmmaMmaAsyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type results, ::mlir::Value inouts, ::mlir::Value descriptorA, ::mlir::Value descriptorB, ::mlir::NVVM::MMAShapeAttr shape, ::mlir::NVVM::WGMMATypes typeA, ::mlir::NVVM::WGMMATypes typeB, ::mlir::NVVM::WGMMATypes typeD, ::mlir::NVVM::WGMMAScaleOut scaleD, ::mlir::NVVM::WGMMAScaleIn scaleA, ::mlir::NVVM::WGMMAScaleIn scaleB, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, /*optional*/::mlir::NVVM::MMAIntOverflowAttr satfinite) { odsState.addOperands(inouts); odsState.addOperands(descriptorA); odsState.addOperands(descriptorB); odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().typeA = ::mlir::NVVM::WGMMATypesAttr::get(odsBuilder.getContext(), typeA); odsState.getOrAddProperties().typeB = ::mlir::NVVM::WGMMATypesAttr::get(odsBuilder.getContext(), typeB); odsState.getOrAddProperties().typeD = ::mlir::NVVM::WGMMATypesAttr::get(odsBuilder.getContext(), typeD); odsState.getOrAddProperties().scaleD = ::mlir::NVVM::WGMMAScaleOutAttr::get(odsBuilder.getContext(), scaleD); odsState.getOrAddProperties().scaleA = ::mlir::NVVM::WGMMAScaleInAttr::get(odsBuilder.getContext(), scaleA); odsState.getOrAddProperties().scaleB = ::mlir::NVVM::WGMMAScaleInAttr::get(odsBuilder.getContext(), scaleB); odsState.getOrAddProperties().layoutA = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layoutA); odsState.getOrAddProperties().layoutB = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layoutB); if (satfinite) { odsState.getOrAddProperties().satfinite = satfinite; } odsState.addTypes(results); } WgmmaMmaAsyncOp WgmmaMmaAsyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type results, ::mlir::Value inouts, ::mlir::Value descriptorA, ::mlir::Value descriptorB, ::mlir::NVVM::MMAShapeAttr shape, ::mlir::NVVM::WGMMATypes typeA, ::mlir::NVVM::WGMMATypes typeB, ::mlir::NVVM::WGMMATypes typeD, ::mlir::NVVM::WGMMAScaleOut scaleD, ::mlir::NVVM::WGMMAScaleIn scaleA, ::mlir::NVVM::WGMMAScaleIn scaleB, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, /*optional*/::mlir::NVVM::MMAIntOverflowAttr satfinite) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(results), std::forward(inouts), std::forward(descriptorA), std::forward(descriptorB), std::forward(shape), std::forward(typeA), std::forward(typeB), std::forward(typeD), std::forward(scaleD), std::forward(scaleA), std::forward(scaleB), std::forward(layoutA), std::forward(layoutB), std::forward(satfinite)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaMmaAsyncOp WgmmaMmaAsyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type results, ::mlir::Value inouts, ::mlir::Value descriptorA, ::mlir::Value descriptorB, ::mlir::NVVM::MMAShapeAttr shape, ::mlir::NVVM::WGMMATypes typeA, ::mlir::NVVM::WGMMATypes typeB, ::mlir::NVVM::WGMMATypes typeD, ::mlir::NVVM::WGMMAScaleOut scaleD, ::mlir::NVVM::WGMMAScaleIn scaleA, ::mlir::NVVM::WGMMAScaleIn scaleB, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, /*optional*/::mlir::NVVM::MMAIntOverflowAttr satfinite) { return create(builder, builder.getLoc(), std::forward(results), std::forward(inouts), std::forward(descriptorA), std::forward(descriptorB), std::forward(shape), std::forward(typeA), std::forward(typeB), std::forward(typeD), std::forward(scaleD), std::forward(scaleA), std::forward(scaleB), std::forward(layoutA), std::forward(layoutB), std::forward(satfinite)); } void WgmmaMmaAsyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value inouts, ::mlir::Value descriptorA, ::mlir::Value descriptorB, ::mlir::NVVM::MMAShapeAttr shape, ::mlir::NVVM::WGMMATypes typeA, ::mlir::NVVM::WGMMATypes typeB, ::mlir::NVVM::WGMMATypes typeD, ::mlir::NVVM::WGMMAScaleOut scaleD, ::mlir::NVVM::WGMMAScaleIn scaleA, ::mlir::NVVM::WGMMAScaleIn scaleB, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, /*optional*/::mlir::NVVM::MMAIntOverflowAttr satfinite) { odsState.addOperands(inouts); odsState.addOperands(descriptorA); odsState.addOperands(descriptorB); odsState.getOrAddProperties().shape = shape; odsState.getOrAddProperties().typeA = ::mlir::NVVM::WGMMATypesAttr::get(odsBuilder.getContext(), typeA); odsState.getOrAddProperties().typeB = ::mlir::NVVM::WGMMATypesAttr::get(odsBuilder.getContext(), typeB); odsState.getOrAddProperties().typeD = ::mlir::NVVM::WGMMATypesAttr::get(odsBuilder.getContext(), typeD); odsState.getOrAddProperties().scaleD = ::mlir::NVVM::WGMMAScaleOutAttr::get(odsBuilder.getContext(), scaleD); odsState.getOrAddProperties().scaleA = ::mlir::NVVM::WGMMAScaleInAttr::get(odsBuilder.getContext(), scaleA); odsState.getOrAddProperties().scaleB = ::mlir::NVVM::WGMMAScaleInAttr::get(odsBuilder.getContext(), scaleB); odsState.getOrAddProperties().layoutA = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layoutA); odsState.getOrAddProperties().layoutB = ::mlir::NVVM::MMALayoutAttr::get(odsBuilder.getContext(), layoutB); if (satfinite) { odsState.getOrAddProperties().satfinite = satfinite; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } WgmmaMmaAsyncOp WgmmaMmaAsyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value inouts, ::mlir::Value descriptorA, ::mlir::Value descriptorB, ::mlir::NVVM::MMAShapeAttr shape, ::mlir::NVVM::WGMMATypes typeA, ::mlir::NVVM::WGMMATypes typeB, ::mlir::NVVM::WGMMATypes typeD, ::mlir::NVVM::WGMMAScaleOut scaleD, ::mlir::NVVM::WGMMAScaleIn scaleA, ::mlir::NVVM::WGMMAScaleIn scaleB, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, /*optional*/::mlir::NVVM::MMAIntOverflowAttr satfinite) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(inouts), std::forward(descriptorA), std::forward(descriptorB), std::forward(shape), std::forward(typeA), std::forward(typeB), std::forward(typeD), std::forward(scaleD), std::forward(scaleA), std::forward(scaleB), std::forward(layoutA), std::forward(layoutB), std::forward(satfinite)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaMmaAsyncOp WgmmaMmaAsyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value inouts, ::mlir::Value descriptorA, ::mlir::Value descriptorB, ::mlir::NVVM::MMAShapeAttr shape, ::mlir::NVVM::WGMMATypes typeA, ::mlir::NVVM::WGMMATypes typeB, ::mlir::NVVM::WGMMATypes typeD, ::mlir::NVVM::WGMMAScaleOut scaleD, ::mlir::NVVM::WGMMAScaleIn scaleA, ::mlir::NVVM::WGMMAScaleIn scaleB, ::mlir::NVVM::MMALayout layoutA, ::mlir::NVVM::MMALayout layoutB, /*optional*/::mlir::NVVM::MMAIntOverflowAttr satfinite) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(inouts), std::forward(descriptorA), std::forward(descriptorB), std::forward(shape), std::forward(typeA), std::forward(typeB), std::forward(typeD), std::forward(scaleD), std::forward(scaleA), std::forward(scaleB), std::forward(layoutA), std::forward(layoutB), std::forward(satfinite)); } void WgmmaMmaAsyncOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } WgmmaMmaAsyncOp WgmmaMmaAsyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaMmaAsyncOp WgmmaMmaAsyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void WgmmaMmaAsyncOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } WgmmaMmaAsyncOp WgmmaMmaAsyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaMmaAsyncOp WgmmaMmaAsyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult WgmmaMmaAsyncOp::verifyInvariantsImpl() { auto tblgen_layoutA = getProperties().layoutA; (void)tblgen_layoutA; if (!tblgen_layoutA) return emitOpError("requires attribute 'layoutA'"); auto tblgen_layoutB = getProperties().layoutB; (void)tblgen_layoutB; if (!tblgen_layoutB) return emitOpError("requires attribute 'layoutB'"); auto tblgen_satfinite = getProperties().satfinite; (void)tblgen_satfinite; auto tblgen_scaleA = getProperties().scaleA; (void)tblgen_scaleA; if (!tblgen_scaleA) return emitOpError("requires attribute 'scaleA'"); auto tblgen_scaleB = getProperties().scaleB; (void)tblgen_scaleB; if (!tblgen_scaleB) return emitOpError("requires attribute 'scaleB'"); auto tblgen_scaleD = getProperties().scaleD; (void)tblgen_scaleD; if (!tblgen_scaleD) return emitOpError("requires attribute 'scaleD'"); auto tblgen_shape = getProperties().shape; (void)tblgen_shape; if (!tblgen_shape) return emitOpError("requires attribute 'shape'"); auto tblgen_typeA = getProperties().typeA; (void)tblgen_typeA; if (!tblgen_typeA) return emitOpError("requires attribute 'typeA'"); auto tblgen_typeB = getProperties().typeB; (void)tblgen_typeB; if (!tblgen_typeB) return emitOpError("requires attribute 'typeB'"); auto tblgen_typeD = getProperties().typeD; (void)tblgen_typeD; if (!tblgen_typeD) return emitOpError("requires attribute 'typeD'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps38(*this, tblgen_shape, "shape"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps69(*this, tblgen_typeA, "typeA"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps69(*this, tblgen_typeB, "typeB"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps69(*this, tblgen_typeD, "typeD"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps70(*this, tblgen_scaleD, "scaleD"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps71(*this, tblgen_scaleA, "scaleA"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps71(*this, tblgen_scaleB, "scaleB"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(*this, tblgen_layoutA, "layoutA"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps34(*this, tblgen_layoutB, "layoutB"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps44(*this, tblgen_satfinite, "satfinite"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps35(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_NVVMOps4(*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_NVVMOps35(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!(((*this->getOperation()).getResult(0).getType() == (*this->getOperation()).getOperand(0).getType()))) return emitOpError("failed to verify that input struct and result struct must be the same type"); return ::mlir::success(); } ::llvm::LogicalResult WgmmaMmaAsyncOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult WgmmaMmaAsyncOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand descriptorARawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> descriptorAOperands(&descriptorARawOperand, 1); ::llvm::SMLoc descriptorAOperandsLoc; (void)descriptorAOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand descriptorBRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> descriptorBOperands(&descriptorBRawOperand, 1); ::llvm::SMLoc descriptorBOperandsLoc; (void)descriptorBOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand inoutsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inoutsOperands(&inoutsRawOperand, 1); ::llvm::SMLoc inoutsOperandsLoc; (void)inoutsOperandsLoc; ::mlir::NVVM::MMAShapeAttr shapeAttr; ::mlir::NVVM::WGMMATypesAttr typeDAttr; ::mlir::NVVM::WGMMAScaleOutAttr scaleDAttr; ::mlir::NVVM::MMAIntOverflowAttr satfiniteAttr; ::mlir::NVVM::WGMMATypesAttr typeAAttr; ::mlir::NVVM::WGMMAScaleInAttr scaleAAttr; ::mlir::NVVM::MMALayoutAttr layoutAAttr; ::mlir::NVVM::WGMMATypesAttr typeBAttr; ::mlir::NVVM::WGMMAScaleInAttr scaleBAttr; ::mlir::NVVM::MMALayoutAttr layoutBAttr; ::mlir::Type inoutsRawType{}; ::llvm::ArrayRef<::mlir::Type> inoutsTypes(&inoutsRawType, 1); ::mlir::Type resultsRawType{}; ::llvm::ArrayRef<::mlir::Type> resultsTypes(&resultsRawType, 1); descriptorAOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(descriptorARawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); descriptorBOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(descriptorBRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); inoutsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(inoutsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(shapeAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (shapeAttr) result.getOrAddProperties().shape = shapeAttr; if (parser.parseComma()) return ::mlir::failure(); if (parser.parseKeyword("D")) return ::mlir::failure(); if (parser.parseLSquare()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(typeDAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (typeDAttr) result.getOrAddProperties().typeD = typeDAttr; if (parser.parseComma()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(scaleDAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (scaleDAttr) result.getOrAddProperties().scaleD = scaleDAttr; if (::mlir::succeeded(parser.parseOptionalComma())) { if (parser.parseCustomAttributeWithFallback(satfiniteAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (satfiniteAttr) result.getOrAddProperties().satfinite = satfiniteAttr; } if (parser.parseRSquare()) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); if (parser.parseKeyword("A")) return ::mlir::failure(); if (parser.parseLSquare()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(typeAAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (typeAAttr) result.getOrAddProperties().typeA = typeAAttr; if (parser.parseComma()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(scaleAAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (scaleAAttr) result.getOrAddProperties().scaleA = scaleAAttr; if (parser.parseComma()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(layoutAAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (layoutAAttr) result.getOrAddProperties().layoutA = layoutAAttr; if (parser.parseRSquare()) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); if (parser.parseKeyword("B")) return ::mlir::failure(); if (parser.parseLSquare()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(typeBAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (typeBAttr) result.getOrAddProperties().typeB = typeBAttr; if (parser.parseComma()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(scaleBAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (scaleBAttr) result.getOrAddProperties().scaleB = scaleBAttr; if (parser.parseComma()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(layoutBAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (layoutBAttr) result.getOrAddProperties().layoutB = layoutBAttr; if (parser.parseRSquare()) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); inoutsRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resultsRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(64); result.addTypes(resultsTypes); if (parser.resolveOperands(inoutsOperands, inoutsTypes, inoutsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(descriptorAOperands, odsBuildableType0, descriptorAOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(descriptorBOperands, odsBuildableType0, descriptorBOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void WgmmaMmaAsyncOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getDescriptorA(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getDescriptorB(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getInouts(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getShapeAttr()); _odsPrinter << ","; _odsPrinter << ' ' << "D"; _odsPrinter << "["; _odsPrinter.printStrippedAttrOrType(getTypeDAttr()); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getScaleDAttr()); if (getSatfiniteAttr()) { _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getSatfiniteAttr()); } _odsPrinter << "]"; _odsPrinter << ","; _odsPrinter << ' ' << "A"; _odsPrinter << "["; _odsPrinter.printStrippedAttrOrType(getTypeAAttr()); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getScaleAAttr()); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getLayoutAAttr()); _odsPrinter << "]"; _odsPrinter << ","; _odsPrinter << ' ' << "B"; _odsPrinter << "["; _odsPrinter.printStrippedAttrOrType(getTypeBAttr()); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getScaleBAttr()); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getLayoutBAttr()); _odsPrinter << "]"; ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("shape"); elidedAttrs.push_back("typeD"); elidedAttrs.push_back("scaleD"); elidedAttrs.push_back("satfinite"); elidedAttrs.push_back("typeA"); elidedAttrs.push_back("scaleA"); elidedAttrs.push_back("layoutA"); elidedAttrs.push_back("typeB"); elidedAttrs.push_back("scaleB"); elidedAttrs.push_back("layoutB"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getInouts().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getResults().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::WgmmaMmaAsyncOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::WgmmaMmaAsyncOpGenericAdaptorBase::Properties) namespace mlir::NVVM { //===----------------------------------------------------------------------===// // ::mlir::NVVM::WgmmaWaitGroupSyncOp definitions //===----------------------------------------------------------------------===// namespace detail { WgmmaWaitGroupSyncOpGenericAdaptorBase::WgmmaWaitGroupSyncOpGenericAdaptorBase(WgmmaWaitGroupSyncOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} uint64_t WgmmaWaitGroupSyncOpGenericAdaptorBase::getGroup() { auto attr = getGroupAttr(); return attr.getValue().getZExtValue(); } } // namespace detail WgmmaWaitGroupSyncOpAdaptor::WgmmaWaitGroupSyncOpAdaptor(WgmmaWaitGroupSyncOp op) : WgmmaWaitGroupSyncOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult WgmmaWaitGroupSyncOpAdaptor::verify(::mlir::Location loc) { auto tblgen_group = getProperties().group; (void)tblgen_group; if (!tblgen_group) return emitError(loc, "'nvvm.wgmma.wait.group.sync.aligned' op requires attribute 'group'"); if (tblgen_group && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_group))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_group).getType().isSignlessInteger(64))))) return emitError(loc, "'nvvm.wgmma.wait.group.sync.aligned' op attribute 'group' failed to satisfy constraint: 64-bit signless integer attribute"); return ::mlir::success(); } ::llvm::LogicalResult WgmmaWaitGroupSyncOp::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.group; auto attr = dict.get("group"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `group` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute WgmmaWaitGroupSyncOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.group; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("group", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code WgmmaWaitGroupSyncOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.group.getAsOpaquePointer())); } std::optional WgmmaWaitGroupSyncOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "group") return prop.group; return std::nullopt; } void WgmmaWaitGroupSyncOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "group") { prop.group = ::llvm::dyn_cast_or_null>(value); return; } } void WgmmaWaitGroupSyncOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.group) attrs.append("group", prop.group); } ::llvm::LogicalResult WgmmaWaitGroupSyncOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getGroupAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps6(attr, "group", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult WgmmaWaitGroupSyncOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.group))) return ::mlir::failure(); return ::mlir::success(); } void WgmmaWaitGroupSyncOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.group); } uint64_t WgmmaWaitGroupSyncOp::getGroup() { auto attr = getGroupAttr(); return attr.getValue().getZExtValue(); } void WgmmaWaitGroupSyncOp::setGroup(uint64_t attrValue) { getProperties().group = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); } void WgmmaWaitGroupSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::IntegerAttr group) { odsState.getOrAddProperties().group = group; } WgmmaWaitGroupSyncOp WgmmaWaitGroupSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::IntegerAttr group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaWaitGroupSyncOp WgmmaWaitGroupSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::IntegerAttr group) { return create(builder, builder.getLoc(), std::forward(group)); } void WgmmaWaitGroupSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr group) { odsState.getOrAddProperties().group = group; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } WgmmaWaitGroupSyncOp WgmmaWaitGroupSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaWaitGroupSyncOp WgmmaWaitGroupSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr group) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(group)); } void WgmmaWaitGroupSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, uint64_t group) { odsState.getOrAddProperties().group = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), group); } WgmmaWaitGroupSyncOp WgmmaWaitGroupSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, uint64_t group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaWaitGroupSyncOp WgmmaWaitGroupSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, uint64_t group) { return create(builder, builder.getLoc(), std::forward(group)); } void WgmmaWaitGroupSyncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, uint64_t group) { odsState.getOrAddProperties().group = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), group); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } WgmmaWaitGroupSyncOp WgmmaWaitGroupSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, uint64_t group) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(group)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaWaitGroupSyncOp WgmmaWaitGroupSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, uint64_t group) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(group)); } void WgmmaWaitGroupSyncOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } WgmmaWaitGroupSyncOp WgmmaWaitGroupSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaWaitGroupSyncOp WgmmaWaitGroupSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void WgmmaWaitGroupSyncOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } WgmmaWaitGroupSyncOp WgmmaWaitGroupSyncOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WgmmaWaitGroupSyncOp WgmmaWaitGroupSyncOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult WgmmaWaitGroupSyncOp::verifyInvariantsImpl() { auto tblgen_group = getProperties().group; (void)tblgen_group; if (!tblgen_group) return emitOpError("requires attribute 'group'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_NVVMOps6(*this, tblgen_group, "group"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult WgmmaWaitGroupSyncOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult WgmmaWaitGroupSyncOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::IntegerAttr groupAttr; { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseCustomAttributeWithFallback(groupAttr, parser.getBuilder().getIntegerType(64))) { return ::mlir::failure(); } if (groupAttr) result.getOrAddProperties().group = groupAttr; return ::mlir::success(); } void WgmmaWaitGroupSyncOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("group"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getGroupAttr()); } } // namespace mlir::NVVM MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::WgmmaWaitGroupSyncOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::NVVM::detail::WgmmaWaitGroupSyncOpGenericAdaptorBase::Properties) #endif // GET_OP_CLASSES