mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-23 17:15:33 +00:00
Added "plugin" command
This commit is contained in:
parent
752650a062
commit
a3494fa9ed
6 changed files with 136 additions and 10 deletions
|
@ -27,7 +27,6 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <libgen.h>
|
||||
#include <dlfcn.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -38,7 +37,7 @@ int main(int argc, char **argv)
|
|||
std::string frontend_command = "auto";
|
||||
std::string backend_command = "auto";
|
||||
std::vector<std::string> passes_commands;
|
||||
std::vector<void*> loaded_modules;
|
||||
std::vector<std::string> plugin_filenames;
|
||||
std::string output_filename = "";
|
||||
std::string scriptfile = "";
|
||||
bool scriptfile_tcl = false;
|
||||
|
@ -82,11 +81,7 @@ int main(int argc, char **argv)
|
|||
passes_commands.push_back("opt");
|
||||
break;
|
||||
case 'm':
|
||||
loaded_modules.push_back(dlopen(optarg, RTLD_LAZY|RTLD_GLOBAL));
|
||||
if (loaded_modules.back() == NULL) {
|
||||
fprintf(stderr, "Can't load module `%s': %s\n", optarg, dlerror());
|
||||
exit(1);
|
||||
}
|
||||
plugin_filenames.push_back(optarg);
|
||||
break;
|
||||
case 'f':
|
||||
frontend_command = optarg;
|
||||
|
@ -239,6 +234,9 @@ int main(int argc, char **argv)
|
|||
|
||||
yosys_setup();
|
||||
|
||||
for (auto &fn : plugin_filenames)
|
||||
load_plugin(fn, {});
|
||||
|
||||
if (optind == argc && passes_commands.size() == 0 && scriptfile.empty()) {
|
||||
if (!got_output_filename)
|
||||
backend_command = "";
|
||||
|
@ -346,9 +344,6 @@ int main(int argc, char **argv)
|
|||
|
||||
yosys_shutdown();
|
||||
|
||||
for (auto mod : loaded_modules)
|
||||
dlclose(mod);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
|
||||
|
@ -98,6 +99,12 @@ void yosys_shutdown()
|
|||
yosys_tcl_interp = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (auto &it : loaded_plugins)
|
||||
dlclose(it.second);
|
||||
|
||||
loaded_plugins.clear();
|
||||
loaded_plugin_aliases.clear();
|
||||
}
|
||||
|
||||
RTLIL::IdString new_id(std::string file, int line, std::string func)
|
||||
|
|
|
@ -132,6 +132,11 @@ extern const char *yosys_version_str;
|
|||
extern std::map<std::string, RTLIL::Design*> saved_designs;
|
||||
extern std::vector<RTLIL::Design*> pushed_designs;
|
||||
|
||||
// from passes/cmds/pluginc.cc
|
||||
extern std::map<std::string, void*> loaded_plugins;
|
||||
extern std::map<std::string, std::string> loaded_plugin_aliases;
|
||||
void load_plugin(std::string filename, std::vector<std::string> aliases);
|
||||
|
||||
YOSYS_NAMESPACE_END
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue