diff --git a/kernel/log.cc b/kernel/log.cc index 50638fdf2..115110ec1 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -600,7 +600,7 @@ void log_dump_val_worker(RTLIL::State v) { std::string log_signal(const RTLIL::SigSpec &sig, bool autoint) { std::stringstream buf; - RTLIL_BACKEND::dump_sigspec(buf, sig, autoint); + RTLIL_BACKEND::dump_sigspec(buf, sig, autoint, RTLIL_BACKEND::DumpMode::Readable); return buf.str(); } @@ -655,21 +655,21 @@ const char *log_id(const RTLIL::Process *obj, const char *nullstr) void log_module(RTLIL::Module *module, std::string indent) { std::stringstream buf; - RTLIL_BACKEND::dump_module(buf, indent, module, module->design, false); + RTLIL_BACKEND::dump_module(buf, indent, module, module->design, false, true, false, RTLIL_BACKEND::DumpMode::Readable); log("%s", buf.str()); } void log_cell(RTLIL::Cell *cell, std::string indent) { std::stringstream buf; - RTLIL_BACKEND::dump_cell(buf, indent, cell); + RTLIL_BACKEND::dump_cell(buf, indent, cell, cell->module ? cell->module->design : nullptr, RTLIL_BACKEND::DumpMode::Readable); log("%s", buf.str()); } void log_wire(RTLIL::Wire *wire, std::string indent) { std::stringstream buf; - RTLIL_BACKEND::dump_wire(buf, indent, wire); + RTLIL_BACKEND::dump_wire(buf, indent, wire, wire->module ? wire->module->design : nullptr, RTLIL_BACKEND::DumpMode::Readable); log("%s", buf.str()); } diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index eed0cd72c..0f49effd5 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -1800,7 +1800,7 @@ void RTLIL::Design::pop_selection() std::string RTLIL::Design::to_rtlil_str(bool only_selected) const { std::ostringstream f; - RTLIL_BACKEND::dump_design(f, const_cast(this), only_selected); + RTLIL_BACKEND::dump_design(f, const_cast(this), only_selected, true, false, RTLIL_BACKEND::DumpMode::Readable); return f.str(); } @@ -4958,7 +4958,7 @@ RTLIL::SigSpec RTLIL::Module::FutureFF(Twine &&name, const RTLIL::SigSpec &sig_e std::string RTLIL::Module::to_rtlil_str() const { std::ostringstream f; - RTLIL_BACKEND::dump_module(f, "", const_cast(this), design, false); + RTLIL_BACKEND::dump_module(f, "", const_cast(this), design, false, true, false, RTLIL_BACKEND::DumpMode::Readable); return f.str(); } @@ -5036,7 +5036,7 @@ void RTLIL::Wire::absorb_attrs(dict &&buf) std::string RTLIL::Wire::to_rtlil_str() const { std::ostringstream f; - RTLIL_BACKEND::dump_wire(f, "", this); + RTLIL_BACKEND::dump_wire(f, "", this, module ? module->design : nullptr, RTLIL_BACKEND::DumpMode::Readable); return f.str(); } @@ -5065,7 +5065,7 @@ RTLIL::Memory::Memory() std::string RTLIL::Memory::to_rtlil_str() const { std::ostringstream f; - RTLIL_BACKEND::dump_memory(f, "", this); + RTLIL_BACKEND::dump_memory(f, "", this, module ? module->design : nullptr, RTLIL_BACKEND::DumpMode::Readable); return f.str(); } @@ -5079,7 +5079,7 @@ RTLIL::Process::Process() : module(nullptr) std::string RTLIL::Process::to_rtlil_str() const { std::ostringstream f; - RTLIL_BACKEND::dump_proc(f, "", this); + RTLIL_BACKEND::dump_proc(f, "", this, module ? module->design : nullptr, RTLIL_BACKEND::DumpMode::Readable); return f.str(); } @@ -5149,7 +5149,7 @@ void RTLIL::Cell::absorb_attrs(dict &&buf) std::string RTLIL::Cell::to_rtlil_str() const { std::ostringstream f; - RTLIL_BACKEND::dump_cell(f, "", this); + RTLIL_BACKEND::dump_cell(f, "", this, module ? module->design : nullptr, RTLIL_BACKEND::DumpMode::Readable); return f.str(); } diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 42e6150c8..e55e774a9 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -3339,6 +3339,14 @@ void RTLIL::Process::rewrite_sigspecs2(T &functor) it->rewrite_sigspecs2(functor); } +// The masq accessors below recover their containing Wire/Cell/Module by +// subtracting offsetof from `this`. Those types are non-standard-layout (base +// classes + virtuals), so offsetof is conditionally-supported, but it is +// well-defined on GCC/Clang for these fixed field offsets. +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winvalid-offsetof" +#endif inline TwineRef RTLIL::WireNameMasq::ref() const { const RTLIL::Wire *w = reinterpret_cast( reinterpret_cast(this) - offsetof(RTLIL::Wire, name)); @@ -3454,6 +3462,9 @@ inline std::string RTLIL::ModuleNameMasq::unescaped() const { return std::string(); return m->design->twines.unescaped_str(id); } +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // -Winvalid-offsetof for masq accessors inline RTLIL::ModuleNameMasq::operator TwineRef() const { return ref(); }