mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 03:32:29 +00:00 
			
		
		
		
	Merge pull request #5138 from YosysHQ/emil/libcache-verbose
libcache: add -quiet and -verbose
This commit is contained in:
		
						commit
						18abf2d4f7
					
				
					 4 changed files with 39 additions and 7 deletions
				
			
		|  | @ -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); | ||||
| 		} | ||||
|  |  | |||
|  | @ -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); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -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); | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue