13 #ifndef MLIR_BYTECODE_BYTECODEREADERCONFIG_H
14 #define MLIR_BYTECODE_BYTECODEREADERCONFIG_H
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/StringRef.h"
23 class DialectBytecodeReader;
35 StringRef dialectName, T &entry) = 0;
39 template <
typename CallableT,
41 std::is_convertible_v<
42 CallableT, std::function<LogicalResult(
45 static std::unique_ptr<AttrTypeBytecodeReader<T>>
48 Processor(CallableT &&readFn)
52 return readFn(reader, dialectName, entry);
55 std::decay_t<CallableT> readFn;
57 return std::make_unique<Processor>(std::forward<CallableT>(readFn));
73 return attributeBytecodeParsers;
77 return typeBytecodeParsers;
84 attributeBytecodeParsers.emplace_back(std::move(parser));
88 typeBytecodeParsers.emplace_back(std::move(parser));
93 template <
typename CallableT>
94 std::enable_if_t<std::is_convertible_v<
99 std::forward<CallableT>(parserFn)));
101 template <
typename CallableT>
102 std::enable_if_t<std::is_convertible_v<
107 std::forward<CallableT>(parserFn)));
112 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.