mirror of
https://github.com/YosysHQ/yosys
synced 2025-09-13 05:01:29 +00:00
Deprecate Const::bitvectorize()
This commit is contained in:
parent
e41bf86cc3
commit
31fc0f53e5
2 changed files with 18 additions and 15 deletions
|
@ -344,7 +344,7 @@ bool RTLIL::Const::operator !=(const RTLIL::Const &other) const
|
||||||
|
|
||||||
std::vector<RTLIL::State>& RTLIL::Const::bits_internal()
|
std::vector<RTLIL::State>& RTLIL::Const::bits_internal()
|
||||||
{
|
{
|
||||||
bitvectorize();
|
bitvectorize_internal();
|
||||||
return get_bits();
|
return get_bits();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,7 +358,7 @@ std::vector<RTLIL::State> RTLIL::Const::to_bits() const
|
||||||
|
|
||||||
bool RTLIL::Const::as_bool() const
|
bool RTLIL::Const::as_bool() const
|
||||||
{
|
{
|
||||||
bitvectorize();
|
bitvectorize_internal();
|
||||||
bitvectype& bv = get_bits();
|
bitvectype& bv = get_bits();
|
||||||
for (size_t i = 0; i < bv.size(); i++)
|
for (size_t i = 0; i < bv.size(); i++)
|
||||||
if (bv[i] == State::S1)
|
if (bv[i] == State::S1)
|
||||||
|
@ -368,7 +368,7 @@ bool RTLIL::Const::as_bool() const
|
||||||
|
|
||||||
int RTLIL::Const::as_int(bool is_signed) const
|
int RTLIL::Const::as_int(bool is_signed) const
|
||||||
{
|
{
|
||||||
bitvectorize();
|
bitvectorize_internal();
|
||||||
bitvectype& bv = get_bits();
|
bitvectype& bv = get_bits();
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
for (size_t i = 0; i < bv.size() && i < 32; i++)
|
for (size_t i = 0; i < bv.size() && i < 32; i++)
|
||||||
|
@ -460,7 +460,7 @@ std::optional<int> RTLIL::Const::as_int_compress(bool is_signed) const
|
||||||
|
|
||||||
std::string RTLIL::Const::as_string(const char* any) const
|
std::string RTLIL::Const::as_string(const char* any) const
|
||||||
{
|
{
|
||||||
bitvectorize();
|
bitvectorize_internal();
|
||||||
bitvectype& bv = get_bits();
|
bitvectype& bv = get_bits();
|
||||||
std::string ret;
|
std::string ret;
|
||||||
ret.reserve(bv.size());
|
ret.reserve(bv.size());
|
||||||
|
@ -498,7 +498,7 @@ std::string RTLIL::Const::decode_string() const
|
||||||
if (auto str = get_if_str())
|
if (auto str = get_if_str())
|
||||||
return *str;
|
return *str;
|
||||||
|
|
||||||
bitvectorize();
|
bitvectorize_internal();
|
||||||
bitvectype& bv = get_bits();
|
bitvectype& bv = get_bits();
|
||||||
const int n = GetSize(bv);
|
const int n = GetSize(bv);
|
||||||
const int n_over_8 = n / 8;
|
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)
|
if (tag == backing_tag::bits)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -573,7 +573,7 @@ void RTLIL::Const::bitvectorize() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTLIL::Const::append(const RTLIL::Const &other) {
|
void RTLIL::Const::append(const RTLIL::Const &other) {
|
||||||
bitvectorize();
|
bitvectorize_internal();
|
||||||
bitvectype& bv = get_bits();
|
bitvectype& bv = get_bits();
|
||||||
bv.insert(bv.end(), other.begin(), other.end());
|
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
|
bool RTLIL::Const::is_fully_zero() const
|
||||||
{
|
{
|
||||||
bitvectorize();
|
bitvectorize_internal();
|
||||||
bitvectype& bv = get_bits();
|
bitvectype& bv = get_bits();
|
||||||
cover("kernel.rtlil.const.is_fully_zero");
|
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
|
bool RTLIL::Const::is_fully_ones() const
|
||||||
{
|
{
|
||||||
bitvectorize();
|
bitvectorize_internal();
|
||||||
bitvectype& bv = get_bits();
|
bitvectype& bv = get_bits();
|
||||||
cover("kernel.rtlil.const.is_fully_ones");
|
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");
|
cover("kernel.rtlil.const.is_fully_def");
|
||||||
|
|
||||||
bitvectorize();
|
bitvectorize_internal();
|
||||||
bitvectype& bv = get_bits();
|
bitvectype& bv = get_bits();
|
||||||
|
|
||||||
for (const auto &bit : bv)
|
for (const auto &bit : bv)
|
||||||
|
@ -631,7 +631,7 @@ bool RTLIL::Const::is_fully_undef() const
|
||||||
{
|
{
|
||||||
cover("kernel.rtlil.const.is_fully_undef");
|
cover("kernel.rtlil.const.is_fully_undef");
|
||||||
|
|
||||||
bitvectorize();
|
bitvectorize_internal();
|
||||||
bitvectype& bv = get_bits();
|
bitvectype& bv = get_bits();
|
||||||
|
|
||||||
for (const auto &bit : bv)
|
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");
|
cover("kernel.rtlil.const.is_fully_undef_x_only");
|
||||||
|
|
||||||
bitvectorize();
|
bitvectorize_internal();
|
||||||
bitvectype& bv = get_bits();
|
bitvectype& bv = get_bits();
|
||||||
|
|
||||||
for (const auto &bit : bv)
|
for (const auto &bit : bv)
|
||||||
|
@ -659,7 +659,7 @@ bool RTLIL::Const::is_onehot(int *pos) const
|
||||||
{
|
{
|
||||||
cover("kernel.rtlil.const.is_onehot");
|
cover("kernel.rtlil.const.is_onehot");
|
||||||
|
|
||||||
bitvectorize();
|
bitvectorize_internal();
|
||||||
bitvectype& bv = get_bits();
|
bitvectype& bv = get_bits();
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
|
@ -739,6 +739,7 @@ private:
|
||||||
bitvectype& get_bits() const;
|
bitvectype& get_bits() const;
|
||||||
std::string& get_str() const;
|
std::string& get_str() const;
|
||||||
std::vector<RTLIL::State>& bits_internal();
|
std::vector<RTLIL::State>& bits_internal();
|
||||||
|
void bitvectorize_internal() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Const() : flags(RTLIL::CONST_FLAG_NONE), tag(backing_tag::bits), bits_(std::vector<RTLIL::State>()) {}
|
Const() : flags(RTLIL::CONST_FLAG_NONE), tag(backing_tag::bits), bits_(std::vector<RTLIL::State>()) {}
|
||||||
|
@ -767,8 +768,11 @@ public:
|
||||||
bool operator ==(const RTLIL::Const &other) const;
|
bool operator ==(const RTLIL::Const &other) const;
|
||||||
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(); }
|
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;
|
bool as_bool() const;
|
||||||
|
|
||||||
// Convert the constant value to a C++ int.
|
// Convert the constant value to a C++ int.
|
||||||
|
@ -797,7 +801,6 @@ public:
|
||||||
std::string decode_string() const;
|
std::string decode_string() const;
|
||||||
int size() const;
|
int size() const;
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
void bitvectorize() const;
|
|
||||||
|
|
||||||
void append(const RTLIL::Const &other);
|
void append(const RTLIL::Const &other);
|
||||||
void set(int i, RTLIL::State state) {
|
void set(int i, RTLIL::State state) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue