mirror of
https://github.com/YosysHQ/yosys
synced 2025-05-15 03:34:45 +00:00
libcache: add -quiet and -verbose
This commit is contained in:
parent
f60bbe64ac
commit
0d621ecc11
3 changed files with 30 additions and 6 deletions
|
@ -29,7 +29,7 @@
|
||||||
{
|
{
|
||||||
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
||||||
log("\n");
|
log("\n");
|
||||||
log(" libcache {-enable|-disable|-purge} { -all | [path]... }\n");
|
log(" libcache [-verbose] {-enable|-disable|-purge} { -all | [path]... }\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
log("Controls the default and per path caching of liberty file data.\n");
|
log("Controls the default and per path caching of liberty file data.\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
|
@ -47,6 +47,13 @@
|
||||||
log("\n");
|
log("\n");
|
||||||
log("Displays the current cache settings and cached paths.\n");
|
log("Displays the current cache settings and cached paths.\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
|
log(" libcache {-verbose|-quiet}\n");
|
||||||
|
log("\n");
|
||||||
|
log("Controls cache use logging.\n");
|
||||||
|
log("\n");
|
||||||
|
log(" -verbose Enable printing info when cache is used\n");
|
||||||
|
log(" -quiet Disable printing info when cache is used (default)\n");
|
||||||
|
log("\n");
|
||||||
}
|
}
|
||||||
void execute(std::vector<std::string> args, RTLIL::Design *) override
|
void execute(std::vector<std::string> args, RTLIL::Design *) override
|
||||||
{
|
{
|
||||||
|
@ -55,6 +62,8 @@
|
||||||
bool purge = false;
|
bool purge = false;
|
||||||
bool all = false;
|
bool all = false;
|
||||||
bool list = false;
|
bool list = false;
|
||||||
|
bool verbose = false;
|
||||||
|
bool quiet = false;
|
||||||
std::vector<std::string> paths;
|
std::vector<std::string> paths;
|
||||||
|
|
||||||
size_t argidx;
|
size_t argidx;
|
||||||
|
@ -79,16 +88,24 @@
|
||||||
list = true;
|
list = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (args[argidx] == "-verbose") {
|
||||||
|
verbose = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (args[argidx] == "-quiet") {
|
||||||
|
quiet = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
std::string fname = args[argidx];
|
std::string fname = args[argidx];
|
||||||
rewrite_filename(fname);
|
rewrite_filename(fname);
|
||||||
paths.push_back(fname);
|
paths.push_back(fname);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int modes = enable + disable + purge + list;
|
int modes = enable + disable + purge + list + verbose + quiet;
|
||||||
if (modes == 0)
|
if (modes == 0)
|
||||||
log_cmd_error("At least one of -enable, -disable, -purge or -list is required.\n");
|
log_cmd_error("At least one of -enable, -disable, -purge, -list,\n-verbose, or -quiet is required.\n");
|
||||||
if (modes > 1)
|
if (modes > 1)
|
||||||
log_cmd_error("Only one of -enable, -disable, -purge or -list may be present.\n");
|
log_cmd_error("Only one of -enable, -disable, -purge, -list,\n-verbose, or -quiet may be present.\n");
|
||||||
|
|
||||||
if (all && !paths.empty())
|
if (all && !paths.empty())
|
||||||
log_cmd_error("The -all option cannot be combined with a list of paths.\n");
|
log_cmd_error("The -all option cannot be combined with a list of paths.\n");
|
||||||
|
@ -121,6 +138,10 @@
|
||||||
LibertyAstCache::instance.cache_path.erase(path);
|
LibertyAstCache::instance.cache_path.erase(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (verbose) {
|
||||||
|
LibertyAstCache::instance.verbose = true;
|
||||||
|
} else if (quiet) {
|
||||||
|
LibertyAstCache::instance.verbose = false;
|
||||||
} else {
|
} else {
|
||||||
log_assert(false);
|
log_assert(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,8 @@ std::shared_ptr<const LibertyAst> LibertyAstCache::cached_ast(const std::string
|
||||||
auto it = cached.find(fname);
|
auto it = cached.find(fname);
|
||||||
if (it == cached.end())
|
if (it == cached.end())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
log("Using cached data for liberty file `%s'\n", fname.c_str());
|
if (verbose)
|
||||||
|
log("Using cached data for liberty file `%s'\n", fname.c_str());
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +52,8 @@ void LibertyAstCache::parsed_ast(const std::string &fname, const std::shared_ptr
|
||||||
bool should_cache = it == cache_path.end() ? cache_by_default : it->second;
|
bool should_cache = it == cache_path.end() ? cache_by_default : it->second;
|
||||||
if (!should_cache)
|
if (!should_cache)
|
||||||
return;
|
return;
|
||||||
log("Caching data for liberty file `%s'\n", fname.c_str());
|
if (verbose)
|
||||||
|
log("Caching data for liberty file `%s'\n", fname.c_str());
|
||||||
cached.emplace(fname, ast);
|
cached.emplace(fname, ast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,6 +140,7 @@ namespace Yosys
|
||||||
dict<std::string, std::shared_ptr<const LibertyAst>> cached;
|
dict<std::string, std::shared_ptr<const LibertyAst>> cached;
|
||||||
|
|
||||||
bool cache_by_default = false;
|
bool cache_by_default = false;
|
||||||
|
bool verbose = false;
|
||||||
dict<std::string, bool> cache_path;
|
dict<std::string, bool> cache_path;
|
||||||
|
|
||||||
std::shared_ptr<const LibertyAst> cached_ast(const std::string &fname);
|
std::shared_ptr<const LibertyAst> cached_ast(const std::string &fname);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue