Compare commits

...

5 Commits

Author SHA1 Message Date
github-actions[bot] 209df95fb9 Bump version 2025-05-24 00:23:33 +00:00
Emil J 18abf2d4f7
Merge pull request #5138 from YosysHQ/emil/libcache-verbose
libcache: add -quiet and -verbose
2025-05-24 00:05:46 +02:00
Emil J. Tywoniak 2ca2ecaa1c libcache: fix help 2025-05-09 12:40:45 +02:00
Emil J. Tywoniak 9d2f9f7557 libcache: fix test 2025-05-09 12:40:38 +02:00
Emil J. Tywoniak 0d621ecc11 libcache: add -quiet and -verbose 2025-05-09 11:36:39 +02:00
5 changed files with 40 additions and 8 deletions

View File

@ -160,7 +160,7 @@ ifeq ($(OS), Haiku)
CXXFLAGS += -D_DEFAULT_SOURCE
endif
YOSYS_VER := 0.53+49
YOSYS_VER := 0.53+60
YOSYS_MAJOR := $(shell echo $(YOSYS_VER) | cut -d'.' -f1)
YOSYS_MINOR := $(shell echo $(YOSYS_VER) | cut -d'.' -f2 | cut -d'+' -f1)
YOSYS_COMMIT := $(shell echo $(YOSYS_VER) | cut -d'+' -f2)

View File

@ -47,6 +47,13 @@
log("\n");
log("Displays the current cache settings and cached paths.\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
{
@ -55,6 +62,8 @@
bool purge = false;
bool all = false;
bool list = false;
bool verbose = false;
bool quiet = false;
std::vector<std::string> paths;
size_t argidx;
@ -79,16 +88,24 @@
list = true;
continue;
}
if (args[argidx] == "-verbose") {
verbose = true;
continue;
}
if (args[argidx] == "-quiet") {
quiet = true;
continue;
}
std::string fname = args[argidx];
rewrite_filename(fname);
paths.push_back(fname);
break;
}
int modes = enable + disable + purge + list;
int modes = enable + disable + purge + list + verbose + quiet;
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)
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())
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);
}
}
} else if (verbose) {
LibertyAstCache::instance.verbose = true;
} else if (quiet) {
LibertyAstCache::instance.verbose = false;
} else {
log_assert(false);
}

View File

@ -41,7 +41,8 @@ std::shared_ptr<const LibertyAst> LibertyAstCache::cached_ast(const std::string
auto it = cached.find(fname);
if (it == cached.end())
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;
}
@ -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;
if (!should_cache)
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);
}

View File

@ -140,6 +140,7 @@ namespace Yosys
dict<std::string, std::shared_ptr<const LibertyAst>> cached;
bool cache_by_default = false;
bool verbose = false;
dict<std::string, bool> cache_path;
std::shared_ptr<const LibertyAst> cached_ast(const std::string &fname);

View File

@ -1,3 +1,4 @@
libcache -verbose
libcache -enable busdef.lib
logger -expect log "Caching is disabled by default." 1
@ -14,8 +15,8 @@ logger -expect log "Caching data" 1
read_liberty -lib busdef.lib; design -reset
logger -check-expected
logger -expect log "Using caching data" 1
log Using caching data
logger -expect log "Using cached data" 1
log Using cached data
read_liberty normal.lib; design -reset
logger -check-expected
@ -23,6 +24,13 @@ logger -expect log "Using cached data" 1
read_liberty -lib busdef.lib; design -reset
logger -check-expected
libcache -quiet
logger -expect log "Using cached data" 1
log Using cached data
read_liberty -lib busdef.lib; design -reset
logger -check-expected
libcache -verbose
libcache -purge busdef.lib
logger -expect log "Caching is disabled by default." 1