From 5a4e4b2dcda1c7e16ab6a583b25cc3055671a647 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 10 Mar 2021 17:47:31 -0500 Subject: [PATCH] Add -Oo to disable const bit tree (#2830). --- src/V3Const.cpp | 1 + src/V3Options.cpp | 4 +++- src/V3Options.h | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/V3Const.cpp b/src/V3Const.cpp index b6b528bc0..d12bb2a40 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -687,6 +687,7 @@ private: return true; } bool matchBitOpTree(AstNode* nodep) { + if (!v3Global.opt.oConstBitOpTree()) return false; AstNode* newp = nullptr; bool tried = false; if (AstAnd* andp = VN_CAST(nodep, And)) { // 1 & BitOpTree diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 1dbb7bd7d..c54149d81 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -1159,7 +1159,8 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char case 'k': m_oSubstConst = flag; break; case 'l': m_oLife = flag; break; case 'm': m_oAssemble = flag; break; - // n o + // n + case 'o': m_oConstBitOpTree = flag; break; // Can remove ~2022-01 when stable case 'p': m_public = !flag; break; // With -Op so flag=0, we want public on so few optimizations done @@ -1864,6 +1865,7 @@ void V3Options::optimize(int level) { m_oCase = flag; m_oCombine = flag; m_oConst = flag; + m_oConstBitOpTree = flag; m_oDedupe = flag; m_oExpand = flag; m_oGate = flag; diff --git a/src/V3Options.h b/src/V3Options.h index 00b9f156c..4db85011a 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -341,6 +341,7 @@ private: bool m_oCase; // main switch: -Oe: case tree conversion bool m_oCombine; // main switch: -Ob: common icode packing bool m_oConst; // main switch: -Oc: constant folding + bool m_oConstBitOpTree; // main switch: -Oo: constant bit op tree bool m_oDedupe; // main switch: -Od: logic deduplication bool m_oExpand; // main switch: -Ox: expansion of C macros bool m_oGate; // main switch: -Og: gate wire elimination @@ -563,6 +564,7 @@ public: bool oCase() const { return m_oCase; } bool oCombine() const { return m_oCombine; } bool oConst() const { return m_oConst; } + bool oConstBitOpTree() const { return m_oConstBitOpTree; } bool oDedupe() const { return m_oDedupe; } bool oExpand() const { return m_oExpand; } bool oGate() const { return m_oGate; }