mirror of https://github.com/YosysHQ/yosys.git
Add API to overwrite existing pass from plugin
Signed-off-by: Claire Xenia Wolf <claire@clairexen.net>
This commit is contained in:
parent
3537976477
commit
4fa314c0bd
|
@ -108,9 +108,8 @@ Pass::Pass(std::string name, std::string short_help) : pass_name(name), short_he
|
||||||
|
|
||||||
void Pass::run_register()
|
void Pass::run_register()
|
||||||
{
|
{
|
||||||
if (pass_register.count(pass_name))
|
if (pass_register.count(pass_name) && !replace_existing_pass())
|
||||||
log_error("Unable to register pass '%s', pass already exists!\n", pass_name.c_str());
|
log_error("Unable to register pass '%s', pass already exists!\n", pass_name.c_str());
|
||||||
|
|
||||||
pass_register[pass_name] = this;
|
pass_register[pass_name] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,13 +446,12 @@ Frontend::Frontend(std::string name, std::string short_help) :
|
||||||
|
|
||||||
void Frontend::run_register()
|
void Frontend::run_register()
|
||||||
{
|
{
|
||||||
if (pass_register.count(pass_name))
|
if (pass_register.count(pass_name) && !replace_existing_pass())
|
||||||
log_error("Unable to register pass '%s', pass already exists!\n", pass_name.c_str());
|
log_error("Unable to register pass '%s', pass already exists!\n", pass_name.c_str());
|
||||||
pass_register[pass_name] = this;
|
pass_register[pass_name] = this;
|
||||||
|
|
||||||
if (frontend_register.count(frontend_name))
|
if (frontend_register.count(frontend_name) && !replace_existing_pass())
|
||||||
log_error("Unable to register frontend '%s', frontend already exists!\n", frontend_name.c_str());
|
log_error("Unable to register frontend '%s', frontend already exists!\n", frontend_name.c_str());
|
||||||
|
|
||||||
frontend_register[frontend_name] = this;
|
frontend_register[frontend_name] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ struct Pass
|
||||||
|
|
||||||
virtual void on_register();
|
virtual void on_register();
|
||||||
virtual void on_shutdown();
|
virtual void on_shutdown();
|
||||||
|
virtual bool replace_existing_pass() const { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ScriptPass : Pass
|
struct ScriptPass : Pass
|
||||||
|
|
|
@ -103,7 +103,6 @@ void load_plugin(std::string filename, std::vector<std::string> aliases)
|
||||||
|
|
||||||
loaded_plugins[orig_filename] = hdl;
|
loaded_plugins[orig_filename] = hdl;
|
||||||
Pass::init_register();
|
Pass::init_register();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue