diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 2b985df40..cbb349a11 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -344,7 +344,7 @@ bool RTLIL::Const::operator !=(const RTLIL::Const &other) const std::vector& RTLIL::Const::bits_internal() { - bitvectorize(); + bitvectorize_internal(); return get_bits(); } @@ -358,7 +358,7 @@ std::vector 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) @@ -368,7 +368,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++) @@ -460,7 +460,7 @@ std::optional 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()); @@ -498,7 +498,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; @@ -547,7 +547,7 @@ bool RTLIL::Const::empty() const { } } -void RTLIL::Const::bitvectorize() const { +void RTLIL::Const::bitvectorize_internal() const { if (tag == backing_tag::bits) return; @@ -573,7 +573,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()); } @@ -589,7 +589,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"); @@ -602,7 +602,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"); @@ -617,7 +617,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) @@ -631,7 +631,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) @@ -645,7 +645,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) @@ -659,7 +659,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; diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 2ffb56052..c1890452c 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -739,6 +739,7 @@ private: bitvectype& get_bits() const; std::string& get_str() const; std::vector& bits_internal(); + void bitvectorize_internal() const; public: Const() : flags(RTLIL::CONST_FLAG_NONE), tag(backing_tag::bits), bits_(std::vector()) {} @@ -767,8 +768,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, that's an implementation detail.")]] std::vector& 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. @@ -797,7 +801,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) {