mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 19:52:31 +00:00 
			
		
		
		
	Merge branch 'rtlil_remove2_speedup' of https://github.com/kc8apf/yosys
This commit is contained in:
		
						commit
						aed8fb353c
					
				
					 2 changed files with 37 additions and 23 deletions
				
			
		|  | @ -2688,31 +2688,43 @@ void RTLIL::SigSpec::remove2(const pool<RTLIL::SigBit> &pattern, RTLIL::SigSpec | |||
| 		other->unpack(); | ||||
| 	} | ||||
| 
 | ||||
| 	std::vector<RTLIL::SigBit> new_bits, new_other_bits; | ||||
| 
 | ||||
| 	new_bits.resize(GetSize(bits_)); | ||||
| 	if (other != NULL) | ||||
| 		new_other_bits.resize(GetSize(bits_)); | ||||
| 
 | ||||
| 	int k = 0; | ||||
| 	for (int i = 0; i < GetSize(bits_); i++) { | ||||
| 		if (bits_[i].wire != NULL && pattern.count(bits_[i])) | ||||
| 			continue; | ||||
| 		if (other != NULL) | ||||
| 			new_other_bits[k] = other->bits_[i]; | ||||
| 		new_bits[k++] = bits_[i]; | ||||
| 	for (int i = GetSize(bits_) - 1; i >= 0; i--) { | ||||
| 		if (bits_[i].wire != NULL && pattern.count(bits_[i])) { | ||||
| 			bits_.erase(bits_.begin() + i); | ||||
| 			width_--; | ||||
| 			if (other != NULL) { | ||||
| 				other->bits_.erase(other->bits_.begin() + i); | ||||
| 				other->width_--; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	new_bits.resize(k); | ||||
| 	if (other != NULL) | ||||
| 		new_other_bits.resize(k); | ||||
| 	check(); | ||||
| } | ||||
| 
 | ||||
| 	bits_.swap(new_bits); | ||||
| 	width_ = GetSize(bits_); | ||||
| void RTLIL::SigSpec::remove2(const std::set<RTLIL::SigBit> &pattern, RTLIL::SigSpec *other) | ||||
| { | ||||
| 	if (other) | ||||
| 		cover("kernel.rtlil.sigspec.remove_other"); | ||||
| 	else | ||||
| 		cover("kernel.rtlil.sigspec.remove"); | ||||
| 
 | ||||
| 	unpack(); | ||||
| 
 | ||||
| 	if (other != NULL) { | ||||
| 		other->bits_.swap(new_other_bits); | ||||
| 		other->width_ = GetSize(other->bits_); | ||||
| 		log_assert(width_ == other->width_); | ||||
| 		other->unpack(); | ||||
| 	} | ||||
| 
 | ||||
| 	for (int i = GetSize(bits_) - 1; i >= 0; i--) { | ||||
| 		if (bits_[i].wire != NULL && pattern.count(bits_[i])) { | ||||
| 			bits_.erase(bits_.begin() + i); | ||||
| 			width_--; | ||||
| 			if (other != NULL) { | ||||
| 				other->bits_.erase(other->bits_.begin() + i); | ||||
| 				other->width_--; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	check(); | ||||
|  |  | |||
|  | @ -192,12 +192,12 @@ namespace RTLIL | |||
| 			return std::string(global_id_storage_.at(index_)); | ||||
| 		} | ||||
| 
 | ||||
| 		bool operator<(IdString rhs) const { | ||||
| 		bool operator<(const IdString &rhs) const { | ||||
| 			return index_ < rhs.index_; | ||||
| 		} | ||||
| 
 | ||||
| 		bool operator==(IdString rhs) const { return index_ == rhs.index_; } | ||||
| 		bool operator!=(IdString rhs) const { return index_ != rhs.index_; } | ||||
| 		bool operator==(const IdString &rhs) const { return index_ == rhs.index_; } | ||||
| 		bool operator!=(const IdString &rhs) const { return index_ != rhs.index_; } | ||||
| 
 | ||||
| 		// The methods below are just convenience functions for better compatibility with std::string.
 | ||||
| 
 | ||||
|  | @ -670,6 +670,8 @@ public: | |||
| 	void remove(const pool<RTLIL::SigBit> &pattern, RTLIL::SigSpec *other) const; | ||||
| 	void remove2(const pool<RTLIL::SigBit> &pattern, RTLIL::SigSpec *other); | ||||
| 
 | ||||
| 	void remove2(const std::set<RTLIL::SigBit> &pattern, RTLIL::SigSpec *other); | ||||
| 
 | ||||
| 	void remove(int offset, int length = 1); | ||||
| 	void remove_const(); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue