10#include <mlir/Bytecode/BytecodeImplementation.h>
17 static mlir::FailureOr<LLZKDialectVersion>
read(mlir::DialectBytecodeReader &reader);
23 void write(mlir::DialectBytecodeWriter &writer)
const;
25 std::string
str()
const;
35template <
typename DialectTy>
41 void writeVersion(mlir::DialectBytecodeWriter &writer)
const override {
42 auto versionOr = writer.getDialectVersion<DialectTy>();
44 if (mlir::succeeded(versionOr)) {
54 std::unique_ptr<mlir::DialectVersion>
55 readVersion(mlir::DialectBytecodeReader &reader)
const override {
57 if (mlir::failed(versionOr)) {
60 return std::make_unique<LLZKDialectVersion>(std::move(*versionOr));
68 mlir::Operation *topLevelOp,
const mlir::DialectVersion &version
72 if (requested == current) {
74 return mlir::success();
76 if (requested > current) {
77 return topLevelOp->emitError().append(
78 "Cannot upgrade from current version ", current.str(),
" to future version ",
84 return topLevelOp->emitWarning().append(
85 "LLZK version ", requested.str(),
" is older than current version ", current.str(),
86 " and no upgrade methods have been implemented. Proceed with caution."
std::unique_ptr< mlir::DialectVersion > readVersion(mlir::DialectBytecodeReader &reader) const override
Read the version of this dialect from the provided reader and return it as a unique_ptr to a dialect ...
mlir::LogicalResult upgradeFromVersion(mlir::Operation *topLevelOp, const mlir::DialectVersion &version) const override
Hook invoked after parsing completed, if a version directive was present and included an entry for th...
void writeVersion(mlir::DialectBytecodeWriter &writer) const override
Writes the current version of the LLZK-lib to the given writer.
LLZKDialectBytecodeInterface(mlir::Dialect *dia)
static const LLZKDialectVersion & CurrentVersion()
LLZKDialectVersion(uint64_t majorV, uint64_t minorV, uint64_t patchV)
bool operator==(const LLZKDialectVersion &other) const
std::strong_ordering operator<=>(const LLZKDialectVersion &other) const
static mlir::FailureOr< LLZKDialectVersion > read(mlir::DialectBytecodeReader &reader)
void write(mlir::DialectBytecodeWriter &writer) const