20 bool preorder(
const IR::Declaration_Constant *dc)
override {
21 if (dc->name ==
"__v1model_version") {
22 const auto *val = dc->initializer->to<IR::Constant>();
23 if (!val || val->value < 0) {
25 "%1%: expected v1model version to be a non-negative number",
29 version =
static_cast<unsigned>(val->value);
31 unsigned initialVersion;
32 unsigned currentVersion;
33 BUG_CHECK(absl::SimpleAtoi(V1Model::versionInitial, &initialVersion) &&
34 absl::SimpleAtoi(V1Model::versionCurrent, ¤tVersion),
35 "Unable to check v1model version");
36 if (version < initialVersion || version > currentVersion) {
38 ErrorType::ERR_UNKNOWN,
39 "%1%: unknown v1model version; initial supported version is %2%, latest is %3%",
40 dc->initializer, initialVersion, currentVersion);
46 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