13 #ifndef MLIR_BYTECODE_BYTECODEREADERCONFIG_H
14 #define MLIR_BYTECODE_BYTECODEREADERCONFIG_H
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/ADT/StringRef.h"
24 class DialectBytecodeReader;
36 StringRef dialectName, T &entry) = 0;
40 template <
typename CallableT,
42 std::is_convertible_v<
46 static std::unique_ptr<AttrTypeBytecodeReader<T>>
49 Processor(CallableT &&readFn)
53 return readFn(reader, dialectName, entry);
56 std::decay_t<CallableT> readFn;
58 return std::make_unique<Processor>(std::forward<CallableT>(readFn));
74 return attributeBytecodeParsers;
78 return typeBytecodeParsers;
85 attributeBytecodeParsers.emplace_back(std::move(parser));
89 typeBytecodeParsers.emplace_back(std::move(parser));
94 template <
typename CallableT>
95 std::enable_if_t<std::is_convertible_v<
100 std::forward<CallableT>(parserFn)));
102 template <
typename CallableT>
103 std::enable_if_t<std::is_convertible_v<
108 std::forward<CallableT>(parserFn)));
113 attributeBytecodeParsers;
A class to interact with the attributes and types parser when parsing MLIR bytecode.
AttrTypeBytecodeReader()=default
virtual LogicalResult read(DialectBytecodeReader &reader, StringRef dialectName, T &entry)=0
static std::unique_ptr< AttrTypeBytecodeReader< T > > fromCallable(CallableT &&readFn)
Return an Attribute/Type printer implemented via the given callable, whose form should match that of ...
virtual ~AttrTypeBytecodeReader()=default
Attributes are known-constant values of operations.
A class containing bytecode-specific configurations of the ParserConfig.
void attachAttributeCallback(std::unique_ptr< AttrTypeBytecodeReader< Attribute >> parser)
Attach a custom bytecode parser callback to the configuration for parsing of custom type/attributes e...
BytecodeReaderConfig()=default
std::enable_if_t< std::is_convertible_v< CallableT, std::function< LogicalResult(DialectBytecodeReader &, StringRef, Type &)> > > attachTypeCallback(CallableT &&parserFn)
void attachTypeCallback(std::unique_ptr< AttrTypeBytecodeReader< Type >> parser)
std::enable_if_t< std::is_convertible_v< CallableT, std::function< LogicalResult(DialectBytecodeReader &, StringRef, Attribute &)> > > attachAttributeCallback(CallableT &&parserFn)
Attach a custom bytecode parser callback to the configuration for parsing of custom type/attributes e...
ArrayRef< std::unique_ptr< AttrTypeBytecodeReader< Attribute > > > getAttributeCallbacks() const
Returns the callbacks available to the parser.
ArrayRef< std::unique_ptr< AttrTypeBytecodeReader< Type > > > getTypeCallbacks() const
This class defines a virtual interface for reading a bytecode stream, providing hooks into the byteco...
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
@ Type
An inlay hint that for a type annotation.
Include the generated interface declarations.
This class represents an efficient way to signal success or failure.