//===- BytecodeImplementation.h - MLIR Bytecode Implementation --*- 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 // //===----------------------------------------------------------------------===// // // This header defines various interfaces and utilities necessary for dialects // to hook into bytecode serialization. // //===----------------------------------------------------------------------===// #ifndef MLIR_BYTECODE_BYTECODEIMPLEMENTATION_H #define MLIR_BYTECODE_BYTECODEIMPLEMENTATION_H #include "mlir/IR/Attributes.h" #include "mlir/IR/Diagnostics.h" #include "mlir/IR/Dialect.h" #include "mlir/IR/DialectInterface.h" #include "mlir/IR/OpImplementation.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Twine.h" namespace mlir { //===--------------------------------------------------------------------===// // Dialect Version Interface. //===--------------------------------------------------------------------===// /// This class is used to represent the version of a dialect, for the purpose /// of polymorphic destruction. class DialectVersion { … }; //===----------------------------------------------------------------------===// // DialectBytecodeReader //===----------------------------------------------------------------------===// /// This class defines a virtual interface for reading a bytecode stream, /// providing hooks into the bytecode reader. As such, this class should only be /// derived and defined by the main bytecode reader, users (i.e. dialects) /// should generally only interact with this class via the /// BytecodeDialectInterface below. class DialectBytecodeReader { … }; //===----------------------------------------------------------------------===// // DialectBytecodeWriter //===----------------------------------------------------------------------===// /// This class defines a virtual interface for writing to a bytecode stream, /// providing hooks into the bytecode writer. As such, this class should only be /// derived and defined by the main bytecode writer, users (i.e. dialects) /// should generally only interact with this class via the /// BytecodeDialectInterface below. class DialectBytecodeWriter { … }; //===----------------------------------------------------------------------===// // BytecodeDialectInterface //===----------------------------------------------------------------------===// class BytecodeDialectInterface : public DialectInterface::Base<BytecodeDialectInterface> { … }; /// Helper for resource handle reading that returns LogicalResult. template <typename T, typename... Ts> static LogicalResult readResourceHandle(DialectBytecodeReader &reader, FailureOr<T> &value, Ts &&...params) { … } /// Helper method that injects context only if needed, this helps unify some of /// the attribute construction methods. template <typename T, typename... Ts> auto get(MLIRContext *context, Ts &&...params) { … } } // namespace mlir #endif // MLIR_BYTECODE_BYTECODEIMPLEMENTATION_H