mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 03:32:29 +00:00 
			
		
		
		
	proc_clean: add -quiet option.
This is useful for other passes that call it often, like bugpoint.
This commit is contained in:
		
							parent
							
								
									030483ffb9
								
							
						
					
					
						commit
						f7a14a5678
					
				
					 1 changed files with 24 additions and 8 deletions
				
			
		|  | @ -143,7 +143,7 @@ void proc_clean_case(RTLIL::CaseRule *cs, bool &did_something, int &count, int m | ||||||
| YOSYS_NAMESPACE_END | YOSYS_NAMESPACE_END | ||||||
| PRIVATE_NAMESPACE_BEGIN | PRIVATE_NAMESPACE_BEGIN | ||||||
| 
 | 
 | ||||||
| void proc_clean(RTLIL::Module *mod, RTLIL::Process *proc, int &total_count) | void proc_clean(RTLIL::Module *mod, RTLIL::Process *proc, int &total_count, bool quiet) | ||||||
| { | { | ||||||
| 	int count = 0; | 	int count = 0; | ||||||
| 	bool did_something = true; | 	bool did_something = true; | ||||||
|  | @ -160,7 +160,7 @@ void proc_clean(RTLIL::Module *mod, RTLIL::Process *proc, int &total_count) | ||||||
| 		did_something = false; | 		did_something = false; | ||||||
| 		proc_clean_case(&proc->root_case, did_something, count, -1); | 		proc_clean_case(&proc->root_case, did_something, count, -1); | ||||||
| 	} | 	} | ||||||
| 	if (count > 0) | 	if (count > 0 && !quiet) | ||||||
| 		log("Found and cleaned up %d empty switch%s in `%s.%s'.\n", count, count == 1 ? "" : "es", mod->name.c_str(), proc->name.c_str()); | 		log("Found and cleaned up %d empty switch%s in `%s.%s'.\n", count, count == 1 ? "" : "es", mod->name.c_str(), proc->name.c_str()); | ||||||
| 	total_count += count; | 	total_count += count; | ||||||
| } | } | ||||||
|  | @ -171,7 +171,10 @@ struct ProcCleanPass : public Pass { | ||||||
| 	{ | 	{ | ||||||
| 		//   |---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("    proc_clean [selection]\n"); | 		log("    proc_clean [options] [selection]\n"); | ||||||
|  | 		log("\n"); | ||||||
|  | 		log("    -quiet\n"); | ||||||
|  | 		log("        do not print any messages.\n"); | ||||||
| 		log("\n"); | 		log("\n"); | ||||||
| 		log("This pass removes empty parts of processes and ultimately removes a process\n"); | 		log("This pass removes empty parts of processes and ultimately removes a process\n"); | ||||||
| 		log("if it contains only empty structures.\n"); | 		log("if it contains only empty structures.\n"); | ||||||
|  | @ -180,9 +183,20 @@ struct ProcCleanPass : public Pass { | ||||||
| 	void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE | 	void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE | ||||||
| 	{ | 	{ | ||||||
| 		int total_count = 0; | 		int total_count = 0; | ||||||
| 		log_header(design, "Executing PROC_CLEAN pass (remove empty switches from decision trees).\n"); | 		bool quiet = false; | ||||||
| 
 | 
 | ||||||
| 		extra_args(args, 1, design); | 		if (find(args.begin(), args.end(), "-quiet") == args.end()) | ||||||
|  | 			log_header(design, "Executing PROC_CLEAN pass (remove empty switches from decision trees).\n"); | ||||||
|  | 
 | ||||||
|  | 		size_t argidx; | ||||||
|  | 		for (argidx = 1; argidx < args.size(); argidx++) | ||||||
|  | 		{ | ||||||
|  | 			if (args[argidx] == "-quiet") { | ||||||
|  | 				quiet = true; | ||||||
|  | 				continue; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		extra_args(args, argidx, design); | ||||||
| 
 | 
 | ||||||
| 		for (auto mod : design->modules()) { | 		for (auto mod : design->modules()) { | ||||||
| 			std::vector<RTLIL::IdString> delme; | 			std::vector<RTLIL::IdString> delme; | ||||||
|  | @ -191,10 +205,11 @@ struct ProcCleanPass : public Pass { | ||||||
| 			for (auto &proc_it : mod->processes) { | 			for (auto &proc_it : mod->processes) { | ||||||
| 				if (!design->selected(mod, proc_it.second)) | 				if (!design->selected(mod, proc_it.second)) | ||||||
| 					continue; | 					continue; | ||||||
| 				proc_clean(mod, proc_it.second, total_count); | 				proc_clean(mod, proc_it.second, total_count, quiet); | ||||||
| 				if (proc_it.second->syncs.size() == 0 && proc_it.second->root_case.switches.size() == 0 && | 				if (proc_it.second->syncs.size() == 0 && proc_it.second->root_case.switches.size() == 0 && | ||||||
| 						proc_it.second->root_case.actions.size() == 0) { | 						proc_it.second->root_case.actions.size() == 0) { | ||||||
| 					log("Removing empty process `%s.%s'.\n", log_id(mod), proc_it.second->name.c_str()); | 					if (!quiet) | ||||||
|  | 						log("Removing empty process `%s.%s'.\n", log_id(mod), proc_it.second->name.c_str()); | ||||||
| 					delme.push_back(proc_it.first); | 					delme.push_back(proc_it.first); | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  | @ -204,7 +219,8 @@ struct ProcCleanPass : public Pass { | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		log("Cleaned up %d empty switch%s.\n", total_count, total_count == 1 ? "" : "es"); | 		if (!quiet) | ||||||
|  | 			log("Cleaned up %d empty switch%s.\n", total_count, total_count == 1 ? "" : "es"); | ||||||
| 	} | 	} | ||||||
| } ProcCleanPass; | } ProcCleanPass; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue