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>
readVersion(mlir::DialectBytecodeReader &reader
57 if (mlir::failed(versionOr)) {
60 return std::make_unique<LLZKDialectVersion>(std::move(*versionOr));
68 mlir::Operation *topLevelOp,
const mlir::DialectVersion &version
72 return mlir::success();
75 if (*llzkVersion > current) {
76 topLevelOp->emitError(
77 mlir::Twine(
"Cannot upgrade from current version ") + current.str() +
78 " to future version " + llzkVersion->str()
80 return mlir::failure();
82 if (*llzkVersion == current) {
84 return mlir::success();
88 topLevelOp->emitWarning(
89 mlir::Twine(
"LLZK version ") + llzkVersion->str() +
" is older than current version " +
90 current.str() +
" and no upgrade methods have been implemented. Proceed with caution."
92 return mlir::failure();
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...
LLZKDialectBytecodeInterface(mlir::Dialect *dialect)
void writeVersion(mlir::DialectBytecodeWriter &writer) const override
Writes the current version of the LLZK-lib to the given writer.
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