14 bool preorder(
const IR::Declaration_Constant *dc)
override {
15 if (dc->name ==
"__v1model_version") {
16 const auto *val = dc->initializer->to<IR::Constant>();
17 if (!val || val->value < 0) {
19 "%1%: expected v1model version to be a non-negative number",
23 version =
static_cast<unsigned>(val->value);
25 unsigned initialVersion;
26 unsigned currentVersion;
27 BUG_CHECK(absl::SimpleAtoi(V1Model::versionInitial, &initialVersion) &&
28 absl::SimpleAtoi(V1Model::versionCurrent, ¤tVersion),
29 "Unable to check v1model version");
30 if (version < initialVersion || version > currentVersion) {
32 ErrorType::ERR_UNKNOWN,
33 "%1%: unknown v1model version; initial supported version is %2%, latest is %3%",
34 dc->initializer, initialVersion, currentVersion);
40 bool preorder(
const IR::Declaration *)
override {
return false; }
void error(const char *format, Args &&...args)
Report an error with the given message.
Definition lib/error.h:58