mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 13:29:12 +00:00 
			
		
		
		
	Deprecate Const::bitvectorize()
This commit is contained in:
		
							parent
							
								
									1e244cd78a
								
							
						
					
					
						commit
						61caa5e042
					
				
					 2 changed files with 18 additions and 15 deletions
				
			
		| 
						 | 
				
			
			@ -380,7 +380,7 @@ bool RTLIL::Const::operator !=(const RTLIL::Const &other) const
 | 
			
		|||
 | 
			
		||||
std::vector<RTLIL::State>& RTLIL::Const::bits_internal()
 | 
			
		||||
{
 | 
			
		||||
	bitvectorize();
 | 
			
		||||
	bitvectorize_internal();
 | 
			
		||||
	return get_bits();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -394,7 +394,7 @@ std::vector<RTLIL::State> RTLIL::Const::to_bits() const
 | 
			
		|||
 | 
			
		||||
bool RTLIL::Const::as_bool() const
 | 
			
		||||
{
 | 
			
		||||
	bitvectorize();
 | 
			
		||||
	bitvectorize_internal();
 | 
			
		||||
	bitvectype& bv = get_bits();
 | 
			
		||||
	for (size_t i = 0; i < bv.size(); i++)
 | 
			
		||||
		if (bv[i] == State::S1)
 | 
			
		||||
| 
						 | 
				
			
			@ -404,7 +404,7 @@ bool RTLIL::Const::as_bool() const
 | 
			
		|||
 | 
			
		||||
int RTLIL::Const::as_int(bool is_signed) const
 | 
			
		||||
{
 | 
			
		||||
	bitvectorize();
 | 
			
		||||
	bitvectorize_internal();
 | 
			
		||||
	bitvectype& bv = get_bits();
 | 
			
		||||
	int32_t ret = 0;
 | 
			
		||||
	for (size_t i = 0; i < bv.size() && i < 32; i++)
 | 
			
		||||
| 
						 | 
				
			
			@ -496,7 +496,7 @@ std::optional<int> RTLIL::Const::as_int_compress(bool is_signed) const
 | 
			
		|||
 | 
			
		||||
std::string RTLIL::Const::as_string(const char* any) const
 | 
			
		||||
{
 | 
			
		||||
	bitvectorize();
 | 
			
		||||
	bitvectorize_internal();
 | 
			
		||||
	bitvectype& bv = get_bits();
 | 
			
		||||
	std::string ret;
 | 
			
		||||
	ret.reserve(bv.size());
 | 
			
		||||
| 
						 | 
				
			
			@ -534,7 +534,7 @@ std::string RTLIL::Const::decode_string() const
 | 
			
		|||
	if (auto str = get_if_str())
 | 
			
		||||
		return *str;
 | 
			
		||||
 | 
			
		||||
	bitvectorize();
 | 
			
		||||
	bitvectorize_internal();
 | 
			
		||||
	bitvectype& bv = get_bits();
 | 
			
		||||
	const int n = GetSize(bv);
 | 
			
		||||
	const int n_over_8 = n / 8;
 | 
			
		||||
| 
						 | 
				
			
			@ -583,7 +583,7 @@ bool RTLIL::Const::empty() const {
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void RTLIL::Const::bitvectorize() const {
 | 
			
		||||
void RTLIL::Const::bitvectorize_internal() const {
 | 
			
		||||
	if (tag == backing_tag::bits)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -609,7 +609,7 @@ void RTLIL::Const::bitvectorize() const {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
void RTLIL::Const::append(const RTLIL::Const &other) {
 | 
			
		||||
	bitvectorize();
 | 
			
		||||
	bitvectorize_internal();
 | 
			
		||||
	bitvectype& bv = get_bits();
 | 
			
		||||
	bv.insert(bv.end(), other.begin(), other.end());
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -625,7 +625,7 @@ RTLIL::State RTLIL::Const::const_iterator::operator*() const {
 | 
			
		|||
 | 
			
		||||
bool RTLIL::Const::is_fully_zero() const
 | 
			
		||||
{
 | 
			
		||||
	bitvectorize();
 | 
			
		||||
	bitvectorize_internal();
 | 
			
		||||
	bitvectype& bv = get_bits();
 | 
			
		||||
	cover("kernel.rtlil.const.is_fully_zero");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -638,7 +638,7 @@ bool RTLIL::Const::is_fully_zero() const
 | 
			
		|||
 | 
			
		||||
bool RTLIL::Const::is_fully_ones() const
 | 
			
		||||
{
 | 
			
		||||
	bitvectorize();
 | 
			
		||||
	bitvectorize_internal();
 | 
			
		||||
	bitvectype& bv = get_bits();
 | 
			
		||||
	cover("kernel.rtlil.const.is_fully_ones");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -653,7 +653,7 @@ bool RTLIL::Const::is_fully_def() const
 | 
			
		|||
{
 | 
			
		||||
	cover("kernel.rtlil.const.is_fully_def");
 | 
			
		||||
 | 
			
		||||
	bitvectorize();
 | 
			
		||||
	bitvectorize_internal();
 | 
			
		||||
	bitvectype& bv = get_bits();
 | 
			
		||||
 | 
			
		||||
	for (const auto &bit : bv)
 | 
			
		||||
| 
						 | 
				
			
			@ -667,7 +667,7 @@ bool RTLIL::Const::is_fully_undef() const
 | 
			
		|||
{
 | 
			
		||||
	cover("kernel.rtlil.const.is_fully_undef");
 | 
			
		||||
 | 
			
		||||
	bitvectorize();
 | 
			
		||||
	bitvectorize_internal();
 | 
			
		||||
	bitvectype& bv = get_bits();
 | 
			
		||||
 | 
			
		||||
	for (const auto &bit : bv)
 | 
			
		||||
| 
						 | 
				
			
			@ -681,7 +681,7 @@ bool RTLIL::Const::is_fully_undef_x_only() const
 | 
			
		|||
{
 | 
			
		||||
	cover("kernel.rtlil.const.is_fully_undef_x_only");
 | 
			
		||||
 | 
			
		||||
	bitvectorize();
 | 
			
		||||
	bitvectorize_internal();
 | 
			
		||||
	bitvectype& bv = get_bits();
 | 
			
		||||
 | 
			
		||||
	for (const auto &bit : bv)
 | 
			
		||||
| 
						 | 
				
			
			@ -695,7 +695,7 @@ bool RTLIL::Const::is_onehot(int *pos) const
 | 
			
		|||
{
 | 
			
		||||
	cover("kernel.rtlil.const.is_onehot");
 | 
			
		||||
 | 
			
		||||
	bitvectorize();
 | 
			
		||||
	bitvectorize_internal();
 | 
			
		||||
	bitvectype& bv = get_bits();
 | 
			
		||||
 | 
			
		||||
	bool found = false;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -838,6 +838,7 @@ private:
 | 
			
		|||
	bitvectype& get_bits() const;
 | 
			
		||||
	std::string& get_str() const;
 | 
			
		||||
	std::vector<RTLIL::State>& bits_internal();
 | 
			
		||||
	void bitvectorize_internal() const;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	Const() : flags(RTLIL::CONST_FLAG_NONE), tag(backing_tag::bits), bits_(std::vector<RTLIL::State>()) {}
 | 
			
		||||
| 
						 | 
				
			
			@ -866,8 +867,11 @@ public:
 | 
			
		|||
	bool operator ==(const RTLIL::Const &other) const;
 | 
			
		||||
	bool operator !=(const RTLIL::Const &other) const;
 | 
			
		||||
 | 
			
		||||
	[[deprecated]]
 | 
			
		||||
	[[deprecated("Don't use direct access to the internal std::vector<State>, that's an implementation detail.")]]
 | 
			
		||||
	std::vector<RTLIL::State>& bits() { return bits_internal(); }
 | 
			
		||||
	[[deprecated("Don't call bitvectorize() directly, it's an implementation detail.")]]
 | 
			
		||||
	void bitvectorize() const { bitvectorize_internal(); }
 | 
			
		||||
 | 
			
		||||
	bool as_bool() const;
 | 
			
		||||
 | 
			
		||||
	// Convert the constant value to a C++ int.
 | 
			
		||||
| 
						 | 
				
			
			@ -896,7 +900,6 @@ public:
 | 
			
		|||
	std::string decode_string() const;
 | 
			
		||||
	int size() const;
 | 
			
		||||
	bool empty() const;
 | 
			
		||||
	void bitvectorize() const;
 | 
			
		||||
 | 
			
		||||
	void append(const RTLIL::Const &other);
 | 
			
		||||
	void set(int i, RTLIL::State state) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue