mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-12 04:03:45 +00:00
sigspec: move construct
This commit is contained in:
parent
6e3bf76ea4
commit
7325863db2
|
@ -4020,28 +4020,6 @@ RTLIL::SigSpec::SigSpec(bool bit)
|
|||
check();
|
||||
}
|
||||
|
||||
void RTLIL::SigSpec::switch_to_packed() const
|
||||
{
|
||||
// TODO change to debug asserts
|
||||
// log_assert(!this->packed_);
|
||||
// log_assert(bits_.size() == 0);
|
||||
RTLIL::SigSpec *that = (RTLIL::SigSpec*)this;
|
||||
that->bits_.~vector();
|
||||
that->packed_ = true;
|
||||
(void)new (&that->chunks_) std::vector<SigChunk>();
|
||||
}
|
||||
|
||||
void RTLIL::SigSpec::switch_to_unpacked() const
|
||||
{
|
||||
// TODO change to debug asserts
|
||||
// log_assert(this->packed_);
|
||||
// log_assert(chunks_.size() == 0);
|
||||
RTLIL::SigSpec *that = (RTLIL::SigSpec*)this;
|
||||
that->chunks_.~vector();
|
||||
that->packed_ = false;
|
||||
(void)new (&that->bits_) std::vector<SigBit>();
|
||||
}
|
||||
|
||||
void RTLIL::SigSpec::pack() const
|
||||
{
|
||||
RTLIL::SigSpec *that = (RTLIL::SigSpec*)this;
|
||||
|
@ -4075,8 +4053,9 @@ void RTLIL::SigSpec::pack() const
|
|||
last_end_offset = bit.offset + 1;
|
||||
}
|
||||
|
||||
that->switch_to_packed();
|
||||
that->chunks_.swap(new_chunks);
|
||||
that->bits_.~vector();
|
||||
that->packed_ = true;
|
||||
(void)new (&that->chunks_) std::vector<SigChunk>(std::move(new_chunks));
|
||||
|
||||
check();
|
||||
}
|
||||
|
@ -4096,10 +4075,10 @@ void RTLIL::SigSpec::unpack() const
|
|||
for (int i = 0; i < c.width; i++)
|
||||
new_bits.emplace_back(c, i);
|
||||
|
||||
that->chunks_.clear();
|
||||
that->hash_ = 0;
|
||||
that->switch_to_unpacked();
|
||||
that->bits_.swap(new_bits);
|
||||
that->chunks_.~vector();
|
||||
that->packed_ = false;
|
||||
(void)new (&that->bits_) std::vector<SigBit>(std::move(new_bits));
|
||||
}
|
||||
|
||||
void RTLIL::SigSpec::updhash() const
|
||||
|
|
|
@ -838,7 +838,7 @@ struct RTLIL::SigSpecConstIterator
|
|||
inline void operator++() { index++; }
|
||||
};
|
||||
|
||||
struct RTLIL::SigSpec
|
||||
struct alignas(64) RTLIL::SigSpec
|
||||
{
|
||||
private:
|
||||
int width_;
|
||||
|
@ -851,8 +851,6 @@ private:
|
|||
|
||||
void pack() const;
|
||||
void unpack() const;
|
||||
void switch_to_packed() const;
|
||||
void switch_to_unpacked() const;
|
||||
void updhash() const;
|
||||
|
||||
inline bool packed() const {
|
||||
|
@ -890,13 +888,13 @@ public:
|
|||
{
|
||||
if (packed_ != other.packed_) {
|
||||
if (packed_) {
|
||||
chunks_.clear();
|
||||
switch_to_unpacked();
|
||||
bits_ = other.bits_;
|
||||
chunks_.~vector();
|
||||
packed_ = false;
|
||||
(void)new (&bits_) std::vector<SigBit>(other.bits_);
|
||||
} else {
|
||||
bits_.clear();
|
||||
switch_to_packed();
|
||||
chunks_ = other.chunks_;
|
||||
bits_.~vector();
|
||||
packed_ = true;
|
||||
(void)new (&chunks_) std::vector<SigChunk>(other.chunks_);
|
||||
}
|
||||
} else {
|
||||
if (packed_)
|
||||
|
|
Loading…
Reference in a new issue