/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |* *| |* Interface Declarations *| |* *| |* Automatically generated file, do not edit! *| |* *| \*===----------------------------------------------------------------------===*/ namespace mlir { /// An interface for operations that can consume memory-space cast-like /// operations. /// /// This interface can be used to bubble-down memory-space cast operations, /// see the `bubble-down-memory-space-casts` pass for an example. class MemorySpaceCastConsumerOpInterface; } // namespace mlir namespace mlir { /// An interface for operations that perform memory-space casts. This /// interface assumes that the cast operation is `pure`. /// /// These operations expect to have a well-defined ptr-like operand, and /// a well-defined target ptr-like result. /// /// This interface also allows to determine whether a cast can be bubbled-down /// by the `MemorySpaceCastConsumerOpInterface`, allowing control over which /// casts can be bubbled-down or not. class MemorySpaceCastOpInterface; } // namespace mlir namespace mlir { /// An interface for operations that can consume memory-space cast-like /// operations. /// /// This interface can be used to bubble-down memory-space cast operations, /// see the `bubble-down-memory-space-casts` pass for an example. namespace detail { struct MemorySpaceCastConsumerOpInterfaceInterfaceTraits { struct Concept { /// The methods defined by the interface. ::llvm::FailureOr>> (*bubbleDownCasts)(const Concept *impl, ::mlir::Operation *, ::mlir::OpBuilder &); }; template class Model : public Concept { public: using Interface = ::mlir::MemorySpaceCastConsumerOpInterface; Model() : Concept{bubbleDownCasts} {} static inline ::llvm::FailureOr>> bubbleDownCasts(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::OpBuilder & builder); }; template class FallbackModel : public Concept { public: using Interface = ::mlir::MemorySpaceCastConsumerOpInterface; FallbackModel() : Concept{bubbleDownCasts} {} static inline ::llvm::FailureOr>> bubbleDownCasts(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::OpBuilder & builder); }; template class ExternalModel : public FallbackModel { public: using ConcreteEntity = ConcreteOp; }; }; template struct MemorySpaceCastConsumerOpInterfaceTrait; } // namespace detail class MemorySpaceCastConsumerOpInterface : public ::mlir::OpInterface { public: using ::mlir::OpInterface::OpInterface; template struct Trait : public detail::MemorySpaceCastConsumerOpInterfaceTrait {}; /// Attempt to bubble-down the incoming cast-like operands. On success /// returns a `std::optional>`, otherwise it returns /// failure. If the optional is `std::nullopt` then the cast was performed /// in place, otherwise the method returns a list of replacement values. /// If new results are produced, these must be compatible with the original /// operation results. /// /// If the operation was not modified in place, then the interface /// guarantees it is valid to erase the original operation. /// If the operation was modified in place, then the interface must /// guarantee no operations were created by the method, and that no further /// IR modification is necessary. /// /// Any implementations of this method must not erase/replace the original /// operation, instead it is the caller responsibility to erase or replace /// the op with the results provided by the method. /// /// Finally, any implementations of this method have to guarantee that the /// IR remains valid at all times. ::llvm::FailureOr>> bubbleDownCasts(::mlir::OpBuilder & builder); }; } // namespace mlir namespace mlir { /// An interface for operations that perform memory-space casts. This /// interface assumes that the cast operation is `pure`. /// /// These operations expect to have a well-defined ptr-like operand, and /// a well-defined target ptr-like result. /// /// This interface also allows to determine whether a cast can be bubbled-down /// by the `MemorySpaceCastConsumerOpInterface`, allowing control over which /// casts can be bubbled-down or not. namespace detail { struct MemorySpaceCastOpInterfaceInterfaceTraits { struct Concept { /// The methods defined by the interface. ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> (*getSourcePtr)(const Concept *impl, ::mlir::Operation *); ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> (*getTargetPtr)(const Concept *impl, ::mlir::Operation *); bool (*isValidMemorySpaceCast)(const Concept *impl, ::mlir::Operation *, ::mlir::PtrLikeTypeInterface, ::mlir::PtrLikeTypeInterface); ::mlir::MemorySpaceCastOpInterface (*cloneMemorySpaceCastOp)(const Concept *impl, ::mlir::Operation *, ::mlir::OpBuilder &, ::mlir::PtrLikeTypeInterface, ::mlir::TypedValue<::mlir::PtrLikeTypeInterface>); bool (*isSourcePromotable)(const Concept *impl, ::mlir::Operation *); }; template class Model : public Concept { public: using Interface = ::mlir::MemorySpaceCastOpInterface; Model() : Concept{getSourcePtr, getTargetPtr, isValidMemorySpaceCast, cloneMemorySpaceCastOp, isSourcePromotable} {} static inline ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> getSourcePtr(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); static inline ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> getTargetPtr(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); static inline bool isValidMemorySpaceCast(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::PtrLikeTypeInterface tgt, ::mlir::PtrLikeTypeInterface src); static inline ::mlir::MemorySpaceCastOpInterface cloneMemorySpaceCastOp(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::OpBuilder & builder, ::mlir::PtrLikeTypeInterface tgt, ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> src); static inline bool isSourcePromotable(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); }; template class FallbackModel : public Concept { public: using Interface = ::mlir::MemorySpaceCastOpInterface; FallbackModel() : Concept{getSourcePtr, getTargetPtr, isValidMemorySpaceCast, cloneMemorySpaceCastOp, isSourcePromotable} {} static inline ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> getSourcePtr(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); static inline ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> getTargetPtr(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); static inline bool isValidMemorySpaceCast(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::PtrLikeTypeInterface tgt, ::mlir::PtrLikeTypeInterface src); static inline ::mlir::MemorySpaceCastOpInterface cloneMemorySpaceCastOp(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::OpBuilder & builder, ::mlir::PtrLikeTypeInterface tgt, ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> src); static inline bool isSourcePromotable(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); }; template class ExternalModel : public FallbackModel { public: using ConcreteEntity = ConcreteOp; }; }; template struct MemorySpaceCastOpInterfaceTrait; } // namespace detail class MemorySpaceCastOpInterface : public ::mlir::OpInterface { public: using ::mlir::OpInterface::OpInterface; template struct Trait : public detail::MemorySpaceCastOpInterfaceTrait {}; /// Returns the source ptr-like value. ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> getSourcePtr(); /// Returns the target ptr-like value. ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> getTargetPtr(); /// Returns whether the memory space cast specified by `tgt` and `src` /// is supported. bool isValidMemorySpaceCast(::mlir::PtrLikeTypeInterface tgt, ::mlir::PtrLikeTypeInterface src); /// Clones the memory space cast op with the given source and target type. ::mlir::MemorySpaceCastOpInterface cloneMemorySpaceCastOp(::mlir::OpBuilder & builder, ::mlir::PtrLikeTypeInterface tgt, ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> src); /// Returns whether the source pointer of the memory-space cast can be used /// by the `MemorySpaceCastConsumerOpInterface::bubbleDownCasts` method to /// promote the source pointer and bubble down the cast. /// /// For example, a cast operation might decide that all casts to the generic /// memory-space can be promoted. bool isSourcePromotable(); /// Returns the underlying `MemorySpaceCastOpInterface` op if `value` /// is produced by a `MemorySpaceCastOpInterface` op, and /// `isSourcePromotable` returns true, otherwise it returns null. static ::mlir::MemorySpaceCastOpInterface getIfPromotableCast(::mlir::Value value) { auto op = ::llvm::dyn_cast_or_null<::mlir::MemorySpaceCastOpInterface>( value.getDefiningOp()); if (!op || !op.isSourcePromotable()) return nullptr; return op; } }; } // namespace mlir namespace mlir::detail { template struct MemorySpaceCastConsumerOpInterfaceTrait : public ::mlir::OpInterface::Trait { }; } // namespace mlir::detail namespace mlir::detail { template struct MemorySpaceCastOpInterfaceTrait : public ::mlir::OpInterface::Trait { static ::llvm::LogicalResult verifyTrait(::mlir::Operation *op) { return ::mlir::detail::verifyMemorySpaceCastOpInterface(op); } }; } // namespace mlir::detail namespace mlir { template ::llvm::FailureOr>> detail::MemorySpaceCastConsumerOpInterfaceInterfaceTraits::Model::bubbleDownCasts(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::OpBuilder & builder) { return (llvm::cast(tablegen_opaque_val)).bubbleDownCasts(builder); } template ::llvm::FailureOr>> detail::MemorySpaceCastConsumerOpInterfaceInterfaceTraits::FallbackModel::bubbleDownCasts(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::OpBuilder & builder) { return static_cast(impl)->bubbleDownCasts(tablegen_opaque_val, builder); } } // namespace mlir namespace mlir { template ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> detail::MemorySpaceCastOpInterfaceInterfaceTraits::Model::getSourcePtr(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { return (llvm::cast(tablegen_opaque_val)).getSourcePtr(); } template ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> detail::MemorySpaceCastOpInterfaceInterfaceTraits::Model::getTargetPtr(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { return (llvm::cast(tablegen_opaque_val)).getTargetPtr(); } template bool detail::MemorySpaceCastOpInterfaceInterfaceTraits::Model::isValidMemorySpaceCast(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::PtrLikeTypeInterface tgt, ::mlir::PtrLikeTypeInterface src) { return (llvm::cast(tablegen_opaque_val)).isValidMemorySpaceCast(tgt, src); } template ::mlir::MemorySpaceCastOpInterface detail::MemorySpaceCastOpInterfaceInterfaceTraits::Model::cloneMemorySpaceCastOp(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::OpBuilder & builder, ::mlir::PtrLikeTypeInterface tgt, ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> src) { return (llvm::cast(tablegen_opaque_val)).cloneMemorySpaceCastOp(builder, tgt, src); } template bool detail::MemorySpaceCastOpInterfaceInterfaceTraits::Model::isSourcePromotable(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { return (llvm::cast(tablegen_opaque_val)).isSourcePromotable(); } template ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> detail::MemorySpaceCastOpInterfaceInterfaceTraits::FallbackModel::getSourcePtr(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { return static_cast(impl)->getSourcePtr(tablegen_opaque_val); } template ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> detail::MemorySpaceCastOpInterfaceInterfaceTraits::FallbackModel::getTargetPtr(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { return static_cast(impl)->getTargetPtr(tablegen_opaque_val); } template bool detail::MemorySpaceCastOpInterfaceInterfaceTraits::FallbackModel::isValidMemorySpaceCast(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::PtrLikeTypeInterface tgt, ::mlir::PtrLikeTypeInterface src) { return static_cast(impl)->isValidMemorySpaceCast(tablegen_opaque_val, tgt, src); } template ::mlir::MemorySpaceCastOpInterface detail::MemorySpaceCastOpInterfaceInterfaceTraits::FallbackModel::cloneMemorySpaceCastOp(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::OpBuilder & builder, ::mlir::PtrLikeTypeInterface tgt, ::mlir::TypedValue<::mlir::PtrLikeTypeInterface> src) { return static_cast(impl)->cloneMemorySpaceCastOp(tablegen_opaque_val, builder, tgt, src); } template bool detail::MemorySpaceCastOpInterfaceInterfaceTraits::FallbackModel::isSourcePromotable(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { return static_cast(impl)->isSourcePromotable(tablegen_opaque_val); } } // namespace mlir