9 #ifndef MLIR_TOOLS_PDLL_AST_TYPES_H_
10 #define MLIR_TOOLS_PDLL_AST_TYPES_H_
46 template <
typename ImplT,
typename BaseT = Type>
55 return type.
getTypeID() == TypeID::get<ImplTy>();
63 explicit operator bool()
const {
return impl; }
67 [[deprecated(
"Use mlir::isa<U>() instead")]]
69 assert(
impl &&
"isa<> used on a null type.");
70 return U::classof(*
this);
72 template <
typename U,
typename V,
typename... Others>
73 [[deprecated(
"Use mlir::isa<U>() instead")]]
75 return isa<U>() ||
isa<V, Others...>();
78 [[deprecated(
"Use mlir::dyn_cast<U>() instead")]]
80 return isa<U>() ? U(
impl) : U(
nullptr);
83 [[deprecated(
"Use mlir::dyn_cast_or_null<U>() instead")]]
85 return (
impl && isa<U>()) ? U(
impl) : U(
nullptr);
88 [[deprecated(
"Use mlir::cast<U>() instead")]]
113 template <
typename T>
115 return static_cast<const T *
>(
impl);
170 std::optional<StringRef> name = std::nullopt,
175 std::optional<StringRef>
getName()
const;
205 using RangeType::RangeType;
220 using RangeType::RangeType;
335 template <
typename To,
typename From>
339 std::is_same_v<mlir::pdll::ast::Type, std::remove_const_t<From>> ||
340 std::is_base_of_v<mlir::pdll::ast::Type, From>>>
346 if constexpr (std::is_base_of_v<To, From>) {
349 return To::classof(ty);
#define MLIR_DECLARE_EXPLICIT_TYPE_ID(CLASS_NAME)
This class provides an efficient unique identifier for a specific C++ type.
This class represents a PDLL type that corresponds to an mlir::Attribute.
static AttributeType get(Context &context)
Return an instance of the Attribute type.
This class represents a PDLL type that corresponds to a constraint.
static ConstraintType get(Context &context)
Return an instance of the Constraint type.
This class represents the main context of the PDLL AST.
This class represents a PDLL type that corresponds to an mlir::Operation.
const ods::Operation * getODSOperation() const
Return the ODS operation that this type refers to, or nullptr if the ODS operation is unknown.
static OperationType get(Context &context, std::optional< StringRef > name=std::nullopt, const ods::Operation *odsOp=nullptr)
Return an instance of the Operation type with an optional operation name.
std::optional< StringRef > getName() const
Return the name of this operation type, or std::nullopt if it doesn't have on.
This class represents a PDLL type that corresponds to a range of elements with a given element type.
Type getElementType() const
Return the element type of this range.
static RangeType get(Context &context, Type elementType)
Return an instance of the Range type with the given element type.
This class represents a PDLL type that corresponds to a rewrite reference.
static RewriteType get(Context &context)
Return an instance of the Rewrite type.
This class represents a PDLL tuple type, i.e.
size_t size() const
Return the number of elements within this tuple.
ArrayRef< StringRef > getElementNames() const
Return the element names of this tuple.
bool empty() const
Return if the tuple has no elements.
ArrayRef< Type > getElementTypes() const
Return the element types of this tuple.
static TupleType get(Context &context, ArrayRef< Type > elementTypes, ArrayRef< StringRef > elementNames)
Return an instance of the Tuple type.
This class represents a PDLL type that corresponds to an mlir::TypeRange.
static TypeRangeType get(Context &context)
Return an instance of the TypeRange type.
static bool classof(Type type)
Provide type casting support.
This class represents a PDLL type that corresponds to an mlir::Type.
static TypeType get(Context &context)
Return an instance of the Type type.
This class provides several utilities when defining derived type classes.
TypeBase< ImplT, BaseT > Base
static bool classof(Type type)
Provide type casting support.
U dyn_cast_or_null() const
TypeID getTypeID() const
Return the TypeID instance of this type.
bool operator!=(const Type &other) const
void print(raw_ostream &os) const
Print this type to the given stream.
Type(Storage *impl=nullptr)
const T * getImplAs() const
Return the internal storage instance of this type reinterpreted as the given derived storage type.
Storage * getImpl() const
Return the internal storage instance of this type.
Type refineWith(Type other) const
Try to refine this type with the one provided.
bool isa() const
Provide type casting support.
bool operator==(const Type &other) const
This class represents a PDLL type that corresponds to an mlir::ValueRange.
static bool classof(Type type)
Provide type casting support.
static ValueRangeType get(Context &context)
Return an instance of the ValueRange type.
This class represents a PDLL type that corresponds to an mlir::Value.
static ValueType get(Context &context)
Return an instance of the Value type.
This class provides an ODS representation of a specific operation.
The OpAsmOpInterface, see OpAsmInterface.td for more details.
llvm::hash_code hash_value(Type type)
raw_ostream & operator<<(raw_ostream &os, Type type)
Include the generated interface declarations.
static bool isPossible(mlir::pdll::ast::Type ty)
static To doCast(mlir::pdll::ast::Type ty)
static bool isEqual(mlir::pdll::ast::Type lhs, mlir::pdll::ast::Type rhs)
static unsigned getHashValue(mlir::pdll::ast::Type val)
static mlir::pdll::ast::Type getTombstoneKey()
static mlir::pdll::ast::Type getEmptyKey()