13#include "llvm/ADT/TypeSwitch.h"
22#define GET_TYPEDEF_CLASSES
23#include "mlir/Dialect/PDL/IR/PDLOpsTypes.cpp.inc"
29void PDLDialect::registerTypes() {
31#define GET_TYPEDEF_LIST
32#include "mlir/Dialect/PDL/IR/PDLOpsTypes.cpp.inc"
41 if (parseResult.has_value())
59 return llvm::isa<PDLDialect>(type.
getDialect());
63 if (
auto rangeType = llvm::dyn_cast<RangeType>(type))
64 return rangeType.getElementType();
81 if (llvm::isa<RangeType>(elementType)) {
83 <<
"element of pdl.range cannot be another range, but got"
87 return RangeType::get(elementType);
90void RangeType::print(AsmPrinter &printer)
const {
98 if (!llvm::isa<PDLType>(elementType) || llvm::isa<RangeType>(elementType)) {
100 <<
"expected element of pdl.range to be one of [!pdl.attribute, "
101 "!pdl.operation, !pdl.type, !pdl.value], but got "
static OptionalParseResult generatedTypeParser(AsmParser &parser, StringRef *mnemonic, Type &value)
These are unused for now.
static LogicalResult generatedTypePrinter(Type def, AsmPrinter &printer)
static Type parsePDLType(AsmParser &parser)
static Type getElementType(Type type, ArrayRef< int32_t > indices, function_ref< InFlightDiagnostic(StringRef)> emitErrorFn)
Walks the given type hierarchy with the given indices, potentially down to component granularity,...
This base class exposes generic asm parser hooks, usable across the various derived parsers.
virtual InFlightDiagnostic emitError(SMLoc loc, const Twine &message={})=0
Emit a diagnostic at the specified location and return failure.
virtual ParseResult parseLess()=0
Parse a '<' token.
virtual SMLoc getCurrentLocation()=0
Get the location of the next token and store it into the argument.
virtual SMLoc getNameLoc() const =0
Return the location of the original name token.
virtual ParseResult parseGreater()=0
Parse a '>' token.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Dialect & getDialect() const
Get the dialect this type is registered to.
static bool classof(Type type)
Type getRangeElementTypeOrSelf(Type type)
If the given type is a range, return its element type, otherwise return the type itself.
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
llvm::function_ref< Fn > function_ref