From ad5005f8f511ffe547ae083cbe5de1417b56d396 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 24 Jan 2026 18:10:59 -0500 Subject: [PATCH] Internals: Add user#Or functions. No functional change. --- src/V3Ast.h | 20 ++++++++++++-------- src/V3OrderGraphBuilder.cpp | 4 ++-- src/V3Timing.cpp | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/V3Ast.h b/src/V3Ast.h index 5005ee8d4..b482c4de5 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -654,8 +654,9 @@ public: void user1p(void* userp) { user1u(VNUser{userp}); } void user1(int val) { user1u(VNUser{val}); } int user1() const { return user1u().toInt(); } - int user1Inc(int val = 1) { int v = user1(); user1(v + val); return v; } - int user1SetOnce() { int v = user1(); if (!v) user1(1); return v; } // Better for cache than user1Inc() + int user1Inc(int val = 1) { const int v = user1(); user1(v + val); return v; } + int user1Or(int val) { const int v = user1(); user1(v | val); return v; } + int user1SetOnce() { const int v = user1(); if (!v) user1(1); return v; } // Better for cache than user1Inc() static void user1ClearTree() { VNUser1InUse::clear(); } // Clear userp()'s across the entire tree VNUser user2u() const VL_MT_STABLE { @@ -668,8 +669,9 @@ public: void user2p(void* userp) { user2u(VNUser{userp}); } void user2(int val) { user2u(VNUser{val}); } int user2() const { return user2u().toInt(); } - int user2Inc(int val = 1) { int v = user2(); user2(v + val); return v; } - int user2SetOnce() { int v = user2(); if (!v) user2(1); return v; } // Better for cache than user2Inc() + int user2Inc(int val = 1) { const int v = user2(); user2(v + val); return v; } + int user2Or(int val) { const int v = user2(); user2(v | val); return v; } + int user2SetOnce() { const int v = user2(); if (!v) user2(1); return v; } // Better for cache than user2Inc() static void user2ClearTree() { VNUser2InUse::clear(); } // Clear userp()'s across the entire tree VNUser user3u() const VL_MT_STABLE { @@ -682,8 +684,9 @@ public: void user3p(void* userp) { user3u(VNUser{userp}); } void user3(int val) { user3u(VNUser{val}); } int user3() const { return user3u().toInt(); } - int user3Inc(int val = 1) { int v = user3(); user3(v + val); return v; } - int user3SetOnce() { int v = user3(); if (!v) user3(1); return v; } // Better for cache than user3Inc() + int user3Inc(int val = 1) { const int v = user3(); user3(v + val); return v; } + int user3Or(int val) { const int v = user3(); user3(v | val); return v; } + int user3SetOnce() { const int v = user3(); if (!v) user3(1); return v; } // Better for cache than user3Inc() static void user3ClearTree() { VNUser3InUse::clear(); } // Clear userp()'s across the entire tree VNUser user4u() const VL_MT_STABLE { @@ -696,8 +699,9 @@ public: void user4p(void* userp) { user4u(VNUser{userp}); } void user4(int val) { user4u(VNUser{val}); } int user4() const { return user4u().toInt(); } - int user4Inc(int val = 1) { int v = user4(); user4(v + val); return v; } - int user4SetOnce() { int v = user4(); if (!v) user4(1); return v; } // Better for cache than user4Inc() + int user4Or(int val) { const int v = user4(); user4(v | val); return v; } + int user4Inc(int val = 1) { const int v = user4(); user4(v + val); return v; } + int user4SetOnce() { const int v = user4(); if (!v) user4(1); return v; } // Better for cache than user4Inc() static void user4ClearTree() { VNUser4InUse::clear(); } // Clear userp()'s across the entire tree // clang-format on diff --git a/src/V3OrderGraphBuilder.cpp b/src/V3OrderGraphBuilder.cpp index c86df1c0d..f76e0a760 100644 --- a/src/V3OrderGraphBuilder.cpp +++ b/src/V3OrderGraphBuilder.cpp @@ -214,7 +214,7 @@ class OrderGraphBuilder final : public VNVisitor { // Variable is produced if (gen) { // Update VarUsage - varscp->user2(varscp->user2() | VU_GEN); + varscp->user2Or(VU_GEN); // Add edges for produced variables if (m_inPost) { if (!varscp->varp()->ignorePostWrite()) { @@ -253,7 +253,7 @@ class OrderGraphBuilder final : public VNVisitor { // Variable is consumed if (con) { // Update VarUsage - varscp->user2(varscp->user2() | VU_CON); + varscp->user2Or(VU_CON); // Add edges if (m_inPost) { // Combinational logic diff --git a/src/V3Timing.cpp b/src/V3Timing.cpp index 770c2127a..11147cf76 100644 --- a/src/V3Timing.cpp +++ b/src/V3Timing.cpp @@ -100,7 +100,7 @@ enum PropagationType : uint8_t { }; // Add timing flag to a node -static void addFlags(AstNode* const nodep, uint8_t flags) { nodep->user2(nodep->user2() | flags); } +static void addFlags(AstNode* const nodep, uint8_t flags) { nodep->user2Or(flags); } // Check if a node has ALL of the expected flags set static bool hasFlags(AstNode* const nodep, uint8_t flags) { return !(~nodep->user2() & flags); }