3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-07-20 14:15:49 +00:00

rtlil: add Module* back-pointer to inner-process AttrObjects

This commit is contained in:
Emil J. Tywoniak 2026-06-05 13:35:46 +02:00
parent 3424c00cd0
commit 29ab42bc4e
2 changed files with 44 additions and 0 deletions

View file

@ -2363,6 +2363,14 @@ public:
struct RTLIL::CaseRule : public RTLIL::AttrObject
{
// Back-pointer to the owning module. Set by the frontend / kernel
// attach path before any src access; the per-Design src meta vector
// is resolved as `module->design`. Frontends that construct an
// inner-process tree must call setModuleRecursive() on the root before
// the tree is consumed (e.g. before set_src_attribute is invoked on
// any nested CaseRule/SwitchRule/MemWriteAction).
RTLIL::Module *module = nullptr;
std::vector<RTLIL::SigSpec> compare;
std::vector<RTLIL::SigSig> actions;
std::vector<RTLIL::SwitchRule*> switches;
@ -2371,6 +2379,12 @@ struct RTLIL::CaseRule : public RTLIL::AttrObject
bool empty() const;
// Walk the whole CaseRule subtree (this case, every switch, every
// nested case, every MemWriteAction inside this process's sync rules
// — those are reached through Process, not here) and set `module` on
// each. Idempotent.
void setModuleRecursive(RTLIL::Module *m);
template<typename T> void rewrite_sigspecs(T &functor);
template<typename T> void rewrite_sigspecs2(T &functor);
RTLIL::CaseRule *clone() const;
@ -2378,6 +2392,9 @@ struct RTLIL::CaseRule : public RTLIL::AttrObject
struct RTLIL::SwitchRule : public RTLIL::AttrObject
{
// Back-pointer to the owning module; see CaseRule::module.
RTLIL::Module *module = nullptr;
RTLIL::SigSpec signal;
std::vector<RTLIL::CaseRule*> cases;
@ -2385,6 +2402,8 @@ struct RTLIL::SwitchRule : public RTLIL::AttrObject
bool empty() const;
void setModuleRecursive(RTLIL::Module *m);
template<typename T> void rewrite_sigspecs(T &functor);
template<typename T> void rewrite_sigspecs2(T &functor);
RTLIL::SwitchRule *clone() const;
@ -2392,6 +2411,9 @@ struct RTLIL::SwitchRule : public RTLIL::AttrObject
struct RTLIL::MemWriteAction : RTLIL::AttrObject
{
// Back-pointer to the owning module; see CaseRule::module.
RTLIL::Module *module = nullptr;
RTLIL::IdString memid;
RTLIL::SigSpec address;
RTLIL::SigSpec data;