//===- Types.h --------------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef MLIR_TOOLS_PDLL_AST_TYPES_H_ #define MLIR_TOOLS_PDLL_AST_TYPES_H_ #include "mlir/Support/LLVM.h" #include "mlir/Support/StorageUniquer.h" #include <optional> namespace mlir { namespace pdll { namespace ods { class Operation; } // namespace ods namespace ast { class Context; namespace detail { struct AttributeTypeStorage; struct ConstraintTypeStorage; struct OperationTypeStorage; struct RangeTypeStorage; struct RewriteTypeStorage; struct TupleTypeStorage; struct TypeTypeStorage; struct ValueTypeStorage; } // namespace detail //===----------------------------------------------------------------------===// // Type //===----------------------------------------------------------------------===// class Type { … }; inline llvm::hash_code hash_value(Type type) { … } inline raw_ostream &operator<<(raw_ostream &os, Type type) { … } //===----------------------------------------------------------------------===// // AttributeType //===----------------------------------------------------------------------===// /// This class represents a PDLL type that corresponds to an mlir::Attribute. class AttributeType : public Type::TypeBase<detail::AttributeTypeStorage> { … }; //===----------------------------------------------------------------------===// // ConstraintType //===----------------------------------------------------------------------===// /// This class represents a PDLL type that corresponds to a constraint. This /// type has no MLIR C++ API correspondance. class ConstraintType : public Type::TypeBase<detail::ConstraintTypeStorage> { … }; //===----------------------------------------------------------------------===// // OperationType //===----------------------------------------------------------------------===// /// This class represents a PDLL type that corresponds to an mlir::Operation. class OperationType : public Type::TypeBase<detail::OperationTypeStorage> { … }; //===----------------------------------------------------------------------===// // RangeType //===----------------------------------------------------------------------===// /// This class represents a PDLL type that corresponds to a range of elements /// with a given element type. class RangeType : public Type::TypeBase<detail::RangeTypeStorage> { … }; //===----------------------------------------------------------------------===// // TypeRangeType /// This class represents a PDLL type that corresponds to an mlir::TypeRange. class TypeRangeType : public RangeType { … }; //===----------------------------------------------------------------------===// // ValueRangeType /// This class represents a PDLL type that corresponds to an mlir::ValueRange. class ValueRangeType : public RangeType { … }; //===----------------------------------------------------------------------===// // RewriteType //===----------------------------------------------------------------------===// /// This class represents a PDLL type that corresponds to a rewrite reference. /// This type has no MLIR C++ API correspondance. class RewriteType : public Type::TypeBase<detail::RewriteTypeStorage> { … }; //===----------------------------------------------------------------------===// // TupleType //===----------------------------------------------------------------------===// /// This class represents a PDLL tuple type, i.e. an ordered set of element /// types with optional names. class TupleType : public Type::TypeBase<detail::TupleTypeStorage> { … }; //===----------------------------------------------------------------------===// // TypeType //===----------------------------------------------------------------------===// /// This class represents a PDLL type that corresponds to an mlir::Type. class TypeType : public Type::TypeBase<detail::TypeTypeStorage> { … }; //===----------------------------------------------------------------------===// // ValueType //===----------------------------------------------------------------------===// /// This class represents a PDLL type that corresponds to an mlir::Value. class ValueType : public Type::TypeBase<detail::ValueTypeStorage> { … }; } // namespace ast } // namespace pdll } // namespace mlir MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::AttributeTypeStorage) MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::ConstraintTypeStorage) MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::OperationTypeStorage) MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::RangeTypeStorage) MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::RewriteTypeStorage) MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::TupleTypeStorage) MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::TypeTypeStorage) MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::ValueTypeStorage) namespace llvm { template <> struct DenseMapInfo<mlir::pdll::ast::Type> { … }; /// Add support for llvm style casts. /// We provide a cast between To and From if From is mlir::pdll::ast::Type or /// derives from it CastInfo<To, From, std::enable_if_t<std::is_same_v<mlir::pdll::ast::Type, std::remove_const_t<From>> || std::is_base_of_v<mlir::pdll::ast::Type, From>>>; } // namespace llvm #endif // MLIR_TOOLS_PDLL_AST_TYPES_H_