10#include <mlir/Bytecode/BytecodeImplementation.h>
16static constexpr auto kV1ConstParamsAttr =
"llzk.v1_const_params";
21 static mlir::FailureOr<LLZKDialectVersion>
read(mlir::DialectBytecodeReader &reader);
27 void write(mlir::DialectBytecodeWriter &writer)
const;
29 std::string
str()
const;
39template <
typename DialectTy>
45 void writeVersion(mlir::DialectBytecodeWriter &writer)
const override {
46 auto versionOr = writer.getDialectVersion<DialectTy>();
48 if (mlir::succeeded(versionOr)) {
58 std::unique_ptr<mlir::DialectVersion>
59 readVersion(mlir::DialectBytecodeReader &reader)
const override {
61 if (mlir::failed(versionOr)) {
64 return std::make_unique<LLZKDialectVersion>(std::move(*versionOr));
75 if (requested == current) {
76 return mlir::success();
78 if (requested > current) {
79 return rootOp->emitError().append(
80 "Cannot upgrade from current version ", current.str(),
" to future version ",
91 assert(requested < current &&
"pre-condition of upgradeFromVersion not met");
94 return mlir::success();
virtual mlir::LogicalResult upgradeFromVersion(mlir::Operation *rootOp, const LLZKDialectVersion ¤t, const LLZKDialectVersion &requested) const
mlir::LogicalResult upgradeFromVersion(mlir::Operation *rootOp, const mlir::DialectVersion &version) const final
Hook invoked for each custom dialect after parsing is completed if a version directive was present an...
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 ...
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