Add -f<optimization> options to replace -O<letter> options (#3436).

This commit is contained in:
Wilson Snyder 2022-06-03 20:43:16 -04:00
parent 173f57c636
commit ada58465b2
73 changed files with 260 additions and 214 deletions

View File

@ -17,6 +17,7 @@ Verilator 4.223 devel
**Minor:**
* Add -f<optimization> options to replace -O<letter> options (#3436).
* Changed --no-merge-const-pool to -fno-merge-const-pool (#3436).
* Support compile time trace signal selection with tracing_on/off (#3323). [Shunyao CAD]
* Add assert when VerilatedContext is mis-deleted (#3121). [Rupert Swarbrick]

View File

@ -319,7 +319,7 @@ detailed descriptions of these arguments.
-f <file> Parse arguments from a file
-FI <file> Force include of a file
--flatten Force inlining of all modules, tasks and functions
--fno-merge-const-pool Disable merging of different types in const pool
--fno-<optimization> Disable internal optimization stage
-G<name>=<value> Overwrite top-level parameter
--gdb Run Verilator under GDB interactively
--gdbbt Run Verilator under GDB for backtrace

View File

@ -20,6 +20,11 @@ Option `--cdc`
The experimental `--cdc` option is believed to be generally unused and is
planned for removal no sooner than January 2023.
Option `--O<letter>`
The debug `--O<letter>` options have been replaced with
`--fno-<optimization>` debug options to match GCC. The old options are
planned for removal no sooner than June 2023.
Option `--prof-threads`
The `--prof-threads` option has been superseded by the `--prof-exec` and
`--prof-pgo` options and is planned for removal no sooner than April 2023.

View File

@ -431,13 +431,51 @@ Summary:
flattening large designs may require significant CPU time, memory and
storage.
.. option:: --fno-acyc-simp
.. option:: --fno-assemble
.. option:: --fno-case
.. option:: --fno-combine
.. option:: --fno-const
.. option:: --fno-const-bit-op-tree
.. option:: --fno-dedup
.. option:: --fno-expand
.. option:: --fno-gate
.. option:: --fno-inline
.. option:: --fno-life
.. option:: --fno-life-post
.. option:: --fno-localize
.. option:: --fno-merge-cond
.. option:: --fno-merge-const-pool
Rarely needed; only use if recommended by maintainers. In order to
minimize cache footprint, values of different data type, that are yet
emitted identically in C++ are merged in the constant pool. This option
disables this and causes every constant pool entry with a distinct data
type to be emitted separately.
.. option:: --fno-reloop
.. option:: --fno-reorder
.. option:: --fno-split
.. option:: --fno-subst
.. option:: --fno-subst-const
.. option:: --fno-table
Rarely needed. Disables one of the internal optimization steps. These
are typically used only when recommended by a maintainer to help debug
or work around an issue.
.. option:: -G<name>=<value>
@ -704,9 +742,9 @@ Summary:
Rarely needed. Enables or disables a specific optimizations, with the
optimization selected based on the letter passed. A lowercase letter
disables an optimization, an upper case letter enables it. This is
intended for debugging use only; see the source code for
version-dependent mappings of optimizations to -O letters.
disables an optimization, an upper case letter enables it. This option
is deprecated and the various `-f<optimization>` arguments should be
used instead.
.. option:: -o <executable>

View File

@ -496,7 +496,7 @@ private:
V3Case::caseLint(nodep);
iterateChildren(nodep);
if (debug() >= 9) nodep->dumpTree(cout, " case_old: ");
if (isCaseTreeFast(nodep) && v3Global.opt.oCase()) {
if (isCaseTreeFast(nodep) && v3Global.opt.fCase()) {
// It's a simple priority encoder or complete statement
// we can make a tree of statements to avoid extra comparisons
++m_statCaseFast;

View File

@ -1090,7 +1090,7 @@ private:
bool matchBitOpTree(AstNode* nodep) {
if (nodep->widthMin() != 1) return false;
if (!v3Global.opt.oConstBitOpTree()) return false;
if (!v3Global.opt.fConstBitOpTree()) return false;
string debugPrefix;
if (debug() >= 9) { // LCOV_EXCL_START
@ -1412,7 +1412,7 @@ private:
return (VN_IS(nodep, And) || VN_IS(nodep, Or) || VN_IS(nodep, Xor));
}
bool ifAdjacentSel(const AstSel* lhsp, const AstSel* rhsp) {
if (!v3Global.opt.oAssemble()) return false; // opt disabled
if (!v3Global.opt.fAssemble()) return false; // opt disabled
if (!lhsp || !rhsp) return false;
const AstNode* const lfromp = lhsp->fromp();
const AstNode* const rfromp = rhsp->fromp();
@ -1427,7 +1427,7 @@ private:
}
bool ifMergeAdjacent(AstNode* lhsp, AstNode* rhsp) {
// called by concatmergeable to determine if {lhsp, rhsp} make sense
if (!v3Global.opt.oAssemble()) return false; // opt disabled
if (!v3Global.opt.fAssemble()) return false; // opt disabled
// two same varref
if (operandsSame(lhsp, rhsp)) return true;
const AstSel* lselp = VN_CAST(lhsp, Sel);
@ -1464,7 +1464,7 @@ private:
}
bool concatMergeable(const AstNode* lhsp, const AstNode* rhsp, unsigned depth) {
// determine if {a OP b, c OP d} => {a, c} OP {b, d} is advantageous
if (!v3Global.opt.oAssemble()) return false; // opt disabled
if (!v3Global.opt.fAssemble()) return false; // opt disabled
if (lhsp->type() != rhsp->type()) return false;
if (!ifConcatMergeableBiop(lhsp)) return false;
if (depth > CONCAT_MERGABLE_MAX_DEPTH) return false; // As worse case O(n^2) algorithm
@ -2550,7 +2550,7 @@ private:
if (nodep->access().isReadOnly()
&& ((!m_params // Can reduce constant wires into equations
&& m_doNConst
&& v3Global.opt.oConst()
&& v3Global.opt.fConst()
// Default value, not a "known" constant for this usage
&& !nodep->varp()->isClassMember()
&& !(nodep->varp()->isFuncLocal() && nodep->varp()->isNonOutput())

View File

@ -397,11 +397,11 @@ private:
// Then propagate more complicated equations
optimizeSignals(true);
// Remove redundant logic
if (v3Global.opt.oDedupe()) {
if (v3Global.opt.fDedupe()) {
dedupe();
if (debug() >= 6) m_graph.dumpDotFilePrefixed("gate_dedup");
}
if (v3Global.opt.oAssemble()) {
if (v3Global.opt.fAssemble()) {
mergeAssigns();
if (debug() >= 6) m_graph.dumpDotFilePrefixed("gate_assm");
}

View File

@ -254,7 +254,7 @@ void GraphAcyc::simplify(bool allowCut) {
if (allowCut) {
// The main algorithm works without these, though slower
// So if changing the main algorithm, comment these out for a test run
if (v3Global.opt.oAcycSimp()) {
if (v3Global.opt.fAcycSimp()) {
cutBasic(vertexp);
cutBackward(vertexp);
}

View File

@ -1082,7 +1082,28 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
parseOptsFile(fl, parseFileArg(optdir, valp), false);
});
DECL_OPTION("-flatten", OnOff, &m_flatten);
DECL_OPTION("-facyc-simp", FOnOff, &m_fAcycSimp);
DECL_OPTION("-fassemble", FOnOff, &m_fAssemble);
DECL_OPTION("-fcase", FOnOff, &m_fCase);
DECL_OPTION("-fcombine", FOnOff, &m_fCombine);
DECL_OPTION("-fconst", FOnOff, &m_fConst);
DECL_OPTION("-fconst-bit-op-tree", FOnOff, &m_fConstBitOpTree);
DECL_OPTION("-fdedup", FOnOff, &m_fDedupe);
DECL_OPTION("-fexpand", FOnOff, &m_fExpand);
DECL_OPTION("-fgate", FOnOff, &m_fGate);
DECL_OPTION("-finline", FOnOff, &m_fInline);
DECL_OPTION("-flife", FOnOff, &m_fLife);
DECL_OPTION("-flife-post", FOnOff, &m_fLifePost);
DECL_OPTION("-flocalize", FOnOff, &m_fLocalize);
DECL_OPTION("-fmerge-cond", FOnOff, &m_fMergeCond);
DECL_OPTION("-fmerge-const-pool", FOnOff, &m_fMergeConstPool);
DECL_OPTION("-freloop", FOnOff, &m_fReloop);
DECL_OPTION("-freorder", FOnOff, &m_fReorder);
DECL_OPTION("-fsplit", FOnOff, &m_fSplit);
DECL_OPTION("-fsubst", FOnOff, &m_fSubst);
DECL_OPTION("-fsubst-const", FOnOff, &m_fSubstConst);
DECL_OPTION("-ftable", FOnOff, &m_fTable);
DECL_OPTION("-G", CbPartialMatch, [this](const char* optp) { addParameter(optp, false); });
DECL_OPTION("-gate-stmts", Set, &m_gateStmts);
@ -1155,47 +1176,49 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
DECL_OPTION("-max-num-width", Set, &m_maxNumWidth);
DECL_OPTION("-mod-prefix", Set, &m_modPrefix);
DECL_OPTION("-O", CbPartialMatch, [this](const char* optp) {
// Optimization
DECL_OPTION("-O0", CbCall, [this]() { optimize(0); });
DECL_OPTION("-O1", CbCall, [this]() { optimize(1); });
DECL_OPTION("-O2", CbCall, [this]() { optimize(2); });
DECL_OPTION("-O3", CbCall, [this]() { optimize(3); });
DECL_OPTION("-O", CbPartialMatch, [this, fl](const char* optp) {
// Optimization, e.g. -O1rX
// LCOV_EXCL_START
fl->v3warn(DEPRECATED, "Option -O<letter> is deprecated. "
"Use -f<optimization> or -fno-<optimization> instead.");
for (const char* cp = optp; *cp; ++cp) {
const bool flag = isupper(*cp);
switch (tolower(*cp)) {
case '0': optimize(0); break; // 0=all off
case '1': optimize(1); break; // 1=all on
case '2': optimize(2); break; // 2=not used
case '3': optimize(3); break; // 3=high
case 'a': m_oTable = flag; break;
case 'b': m_oCombine = flag; break;
case 'c': m_oConst = flag; break;
case 'd': m_oDedupe = flag; break;
case 'e': m_oCase = flag; break;
// f
case 'g': m_oGate = flag; break;
// h
case 'i': m_oInline = flag; break;
// j
case 'k': m_oSubstConst = flag; break;
case 'l': m_oLife = flag; break;
case 'm': m_oAssemble = flag; break;
// n
case 'o':
m_oConstBitOpTree = flag;
break; // Can remove ~2022-01 when stable
// o will be used as an escape for a second character of optimization disables
case '0': optimize(0); break;
case '1': optimize(1); break;
case '2': optimize(2); break;
case '3': optimize(3); break;
case 'a': m_fTable = flag; break; // == -fno-table
case 'b': m_fCombine = flag; break; // == -fno-combine
case 'c': m_fConst = flag; break; // == -fno-const
case 'd': m_fDedupe = flag; break; // == -fno-dedup
case 'e': m_fCase = flag; break; // == -fno-case
case 'g': m_fGate = flag; break; // == -fno-gate
case 'i': m_fInline = flag; break; // == -fno-inline
case 'k': m_fSubstConst = flag; break; // == -fno-subst-const
case 'l': m_fLife = flag; break; // == -fno-life
case 'm': m_fAssemble = flag; break; // == -fno-assemble
case 'o': m_fConstBitOpTree = flag; break; // == -fno-const-bit-op-tree
case 'p':
m_public = !flag;
break; // With -Op so flag=0, we want public on so few optimizations done
// q
case 'r': m_oReorder = flag; break;
case 's': m_oSplit = flag; break;
case 't': m_oLifePost = flag; break;
case 'u': m_oSubst = flag; break;
case 'v': m_oReloop = flag; break;
case 'w': m_oMergeCond = flag; break;
case 'x': m_oExpand = flag; break;
case 'y': m_oAcycSimp = flag; break;
case 'z': m_oLocalize = flag; break;
default: break; // No error, just ignore
case 'r': m_fReorder = flag; break; // == -fno-reorder
case 's': m_fSplit = flag; break; // == -fno-split
case 't': m_fLifePost = flag; break; // == -fno-life-post
case 'u': m_fSubst = flag; break; // == -fno-subst
case 'v': m_fReloop = flag; break; // == -fno-reloop
case 'w': m_fMergeCond = flag; break; // == -fno-merge-cond
case 'x': m_fExpand = flag; break; // == -fno-expand
case 'y': m_fAcycSimp = flag; break; // == -fno-acyc-simp
case 'z': m_fLocalize = flag; break; // == -fno-localize
default:
break; // No error, just ignore
// LCOV_EXCL_STOP
}
}
});
@ -1787,26 +1810,26 @@ int V3Options::dumpTreeLevel(const string& srcfile_path) {
void V3Options::optimize(int level) {
// Set all optimizations to on/off
const bool flag = level > 0;
m_oAcycSimp = flag;
m_oAssemble = flag;
m_oCase = flag;
m_oCombine = flag;
m_oConst = flag;
m_oConstBitOpTree = flag;
m_oDedupe = flag;
m_oExpand = flag;
m_oGate = flag;
m_oInline = flag;
m_oLife = flag;
m_oLifePost = flag;
m_oLocalize = flag;
m_oMergeCond = flag;
m_oReloop = flag;
m_oReorder = flag;
m_oSplit = flag;
m_oSubst = flag;
m_oSubstConst = flag;
m_oTable = flag;
m_fAcycSimp = flag;
m_fAssemble = flag;
m_fCase = flag;
m_fCombine = flag;
m_fConst = flag;
m_fConstBitOpTree = flag;
m_fDedupe = flag;
m_fExpand = flag;
m_fGate = flag;
m_fInline = flag;
m_fLife = flag;
m_fLifePost = flag;
m_fLocalize = flag;
m_fMergeCond = flag;
m_fReloop = flag;
m_fReorder = flag;
m_fSplit = flag;
m_fSubst = flag;
m_fSubstConst = flag;
m_fTable = flag;
// And set specific optimization levels
if (level >= 3) {
m_inlineMult = -1; // Maximum inlining

View File

@ -239,7 +239,6 @@ private:
bool m_dumpDefines = false; // main switch: --dump-defines
bool m_dumpTreeAddrids = false; // main switch: --dump-tree-addrids
bool m_exe = false; // main switch: --exe
bool m_fMergeConstPool = true; // main switch: --fmerge-const-pool
bool m_flatten = false; // main switch: --flatten
bool m_hierarchical = false; // main switch: --hierarchical
bool m_hierChild = false; // main switch: --hierarchical-child
@ -341,27 +340,27 @@ private:
V3LangCode m_defaultLanguage; // main switch: --language
// MEMBERS (optimizations)
// // main switch: -Op: --public
bool m_oAcycSimp; // main switch: -Oy: acyclic pre-optimizations
bool m_oAssemble; // main switch: -Om: assign assemble
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
bool m_oInline; // main switch: -Oi: module inlining
bool m_oLife; // main switch: -Ol: variable lifetime
bool m_oLifePost; // main switch: -Ot: delayed assignment elimination
bool m_oLocalize; // main switch: -Oz: convert temps to local variables
bool m_oMergeCond; // main switch: -Ob: merge conditionals
bool m_oReloop; // main switch: -Ov: reform loops
bool m_oReorder; // main switch: -Or: reorder assignments in blocks
bool m_oSplit; // main switch: -Os: always assignment splitting
bool m_oSubst; // main switch: -Ou: substitute expression temp values
bool m_oSubstConst; // main switch: -Ok: final constant substitution
bool m_oTable; // main switch: -Oa: lookup table creation
bool m_fAcycSimp; // main switch: -fno-acyc-simp: acyclic pre-optimizations
bool m_fAssemble; // main switch: -fno-assemble: assign assemble
bool m_fCase; // main switch: -fno-case: case tree conversion
bool m_fCombine; // main switch: -fno-combine: common icode packing
bool m_fConst; // main switch: -fno-const: constant folding
bool m_fConstBitOpTree; // main switch: -fno-const-bit-op-tree constant bit op tree
bool m_fDedupe; // main switch: -fno-dedupe: logic deduplication
bool m_fExpand; // main switch: -fno-expand: expansion of C macros
bool m_fGate; // main switch: -fno-gate: gate wire elimination
bool m_fInline; // main switch: -fno-inline: module inlining
bool m_fLife; // main switch: -fno-life: variable lifetime
bool m_fLifePost; // main switch: -fno-life-post: delayed assignment elimination
bool m_fLocalize; // main switch: -fno-localize: convert temps to local variables
bool m_fMergeCond; // main switch: -fno-merge-cond: merge conditionals
bool m_fMergeConstPool = true; // main switch: --fmerge-const-pool
bool m_fReloop; // main switch: -fno-reloop: reform loops
bool m_fReorder; // main switch: -fno-reorder: reorder assignments in blocks
bool m_fSplit; // main switch: -fno-split: always assignment splitting
bool m_fSubst; // main switch: -fno-subst: substitute expression temp values
bool m_fSubstConst; // main switch: -fno-subst-const: final constant substitution
bool m_fTable; // main switch: -fno-table: lookup table creation
// clang-format on
bool m_available = false; // Set to true at the end of option parsing
@ -448,7 +447,6 @@ public:
bool dpiHdrOnly() const { return m_dpiHdrOnly; }
bool dumpDefines() const { return m_dumpDefines; }
bool exe() const { return m_exe; }
bool fMergeConstPool() const { return m_fMergeConstPool; }
bool flatten() const { return m_flatten; }
bool gmake() const { return m_gmake; }
bool threadsDpiPure() const { return m_threadsDpiPure; }
@ -575,26 +573,27 @@ public:
bool isNoClocker(const string& signame) const;
// ACCESSORS (optimization options)
bool oAcycSimp() const { return m_oAcycSimp; }
bool oAssemble() const { return m_oAssemble; }
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; }
bool oInline() const { return m_oInline; }
bool oLife() const { return m_oLife; }
bool oLifePost() const { return m_oLifePost; }
bool oLocalize() const { return m_oLocalize; }
bool oMergeCond() const { return m_oMergeCond; }
bool oReloop() const { return m_oReloop; }
bool oReorder() const { return m_oReorder; }
bool oSplit() const { return m_oSplit; }
bool oSubst() const { return m_oSubst; }
bool oSubstConst() const { return m_oSubstConst; }
bool oTable() const { return m_oTable; }
bool fAcycSimp() const { return m_fAcycSimp; }
bool fAssemble() const { return m_fAssemble; }
bool fCase() const { return m_fCase; }
bool fCombine() const { return m_fCombine; }
bool fConst() const { return m_fConst; }
bool fConstBitOpTree() const { return m_fConstBitOpTree; }
bool fDedupe() const { return m_fDedupe; }
bool fExpand() const { return m_fExpand; }
bool fGate() const { return m_fGate; }
bool fInline() const { return m_fInline; }
bool fLife() const { return m_fLife; }
bool fLifePost() const { return m_fLifePost; }
bool fLocalize() const { return m_fLocalize; }
bool fMergeCond() const { return m_fMergeCond; }
bool fMergeConstPool() const { return m_fMergeConstPool; }
bool fReloop() const { return m_fReloop; }
bool fReorder() const { return m_fReorder; }
bool fSplit() const { return m_fSplit; }
bool fSubst() const { return m_fSubst; }
bool fSubstConst() const { return m_fSubstConst; }
bool fTable() const { return m_fTable; }
string traceClassBase() const { return m_traceFormat.classBase(); }
string traceClassLang() const { return m_traceFormat.classBase() + (systemC() ? "Sc" : "C"); }

View File

@ -239,7 +239,7 @@ static void process() {
// Module inlining
// Cannot remove dead variables after this, as alias information for final
// V3Scope's V3LinkDot is in the AstVar.
if (v3Global.opt.oInline()) {
if (v3Global.opt.fInline()) {
V3Inline::inlineAll(v3Global.rootp());
V3LinkDot::linkDotArrayed(v3Global.rootp()); // Cleanup as made new modules
}
@ -310,11 +310,11 @@ static void process() {
// Push constants across variables and remove redundant assignments
V3Const::constifyAll(v3Global.rootp());
if (v3Global.opt.oLife()) V3Life::lifeAll(v3Global.rootp());
if (v3Global.opt.fLife()) V3Life::lifeAll(v3Global.rootp());
// Make large low-fanin logic blocks into lookup tables
// This should probably be done much later, once we have common logic elimination.
if (!v3Global.opt.lintOnly() && v3Global.opt.oTable()) {
if (!v3Global.opt.lintOnly() && v3Global.opt.fTable()) {
V3Table::tableAll(v3Global.rootp());
}
@ -328,7 +328,7 @@ static void process() {
V3Active::activeAll(v3Global.rootp());
// Split single ALWAYS blocks into multiple blocks for better ordering chances
if (v3Global.opt.oSplit()) V3Split::splitAlwaysAll(v3Global.rootp());
if (v3Global.opt.fSplit()) V3Split::splitAlwaysAll(v3Global.rootp());
V3SplitAs::splitAsAll(v3Global.rootp());
// Create tracing sample points, before we start eliminating signals
@ -340,11 +340,11 @@ static void process() {
// Gate-based logic elimination; eliminate signals and push constant across cell boundaries
// Instant propagation makes lots-o-constant reduction possibilities.
if (v3Global.opt.oGate()) {
if (v3Global.opt.fGate()) {
V3Gate::gateAll(v3Global.rootp());
// V3Gate calls constant propagation itself.
} else {
v3info("Command Line disabled gate optimization with -Og/-O0. "
v3info("Command Line disabled gate optimization with -fno-gate. "
"This may cause ordering problems.");
}
@ -363,7 +363,7 @@ static void process() {
}
// Reorder assignments in pipelined blocks
if (v3Global.opt.oReorder()) V3Split::splitReorderAll(v3Global.rootp());
if (v3Global.opt.fReorder()) V3Split::splitReorderAll(v3Global.rootp());
// Create delayed assignments
// This creates lots of duplicate ACTIVES so ActiveTop needs to be after this step
@ -388,11 +388,11 @@ static void process() {
// Cleanup any dly vars or other temps that are simple assignments
// Life must be done before Subst, as it assumes each CFunc under
// _eval is called only once.
if (v3Global.opt.oLife()) {
if (v3Global.opt.fLife()) {
V3Const::constifyAll(v3Global.rootp());
V3Life::lifeAll(v3Global.rootp());
}
if (v3Global.opt.oLifePost()) V3LifePost::lifepostAll(v3Global.rootp());
if (v3Global.opt.fLifePost()) V3LifePost::lifepostAll(v3Global.rootp());
// Remove unused vars
V3Const::constifyAll(v3Global.rootp());
@ -422,13 +422,13 @@ static void process() {
v3Global.assertScoped(false);
// Move variables from modules to function local variables where possible
if (v3Global.opt.oLocalize()) V3Localize::localizeAll(v3Global.rootp());
if (v3Global.opt.fLocalize()) V3Localize::localizeAll(v3Global.rootp());
// Remove remaining scopes; make varrefs/funccalls relative to current module
V3Descope::descopeAll(v3Global.rootp());
// Icache packing; combine common code in each module's functions into subroutines
if (v3Global.opt.oCombine()) V3Combine::combineAll(v3Global.rootp());
if (v3Global.opt.fCombine()) V3Combine::combineAll(v3Global.rootp());
}
V3Error::abortIfErrors();
@ -452,30 +452,30 @@ static void process() {
}
// Expand macros and wide operators into C++ primitives
if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && v3Global.opt.oExpand()) {
if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && v3Global.opt.fExpand()) {
V3Expand::expandAll(v3Global.rootp());
}
// Propagate constants across WORDSEL arrayed temporaries
if (!v3Global.opt.xmlOnly() && v3Global.opt.oSubst()) {
if (!v3Global.opt.xmlOnly() && v3Global.opt.fSubst()) {
// Constant folding of expanded stuff
V3Const::constifyCpp(v3Global.rootp());
V3Subst::substituteAll(v3Global.rootp());
}
if (!v3Global.opt.xmlOnly() && v3Global.opt.oSubstConst()) {
if (!v3Global.opt.xmlOnly() && v3Global.opt.fSubstConst()) {
// Constant folding of substitutions
V3Const::constifyCpp(v3Global.rootp());
V3Dead::deadifyAll(v3Global.rootp());
}
if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly()) {
if (v3Global.opt.oMergeCond()) {
if (v3Global.opt.fMergeCond()) {
// Merge conditionals
V3MergeCond::mergeAll(v3Global.rootp());
}
if (v3Global.opt.oReloop()) {
if (v3Global.opt.fReloop()) {
// Reform loops to reduce code size
// Must be after all Sel/array index based optimizations
V3Reloop::reloopAll(v3Global.rootp());

View File

@ -77,7 +77,6 @@ my $opt_gdbbt;
my $opt_gdbsim;
my $opt_hashset;
my $opt_jobs = 1;
my $opt_optimize;
my $opt_quiet;
my $opt_rerun;
my $opt_rrsim;
@ -104,7 +103,6 @@ if (! GetOptions(
"hashset=s" => \$opt_hashset,
"help" => \&usage,
"j=i" => \$opt_jobs,
"optimize:s" => \$opt_optimize,
"quiet!" => \$opt_quiet,
"rerun!" => \$opt_rerun,
"rr!" => \$opt_rr,
@ -661,7 +659,7 @@ sub new {
verilator_define => 'VERILATOR',
verilator_flags => ["-cc",
"-Mdir $self->{obj_dir}",
"-OD", # As currently disabled unless -O3
"--fdedup", # As currently disabled unless -O3
"--debug-check",
"--comp-limit-members 10", ],
verilator_flags2 => [],
@ -934,19 +932,6 @@ sub compile_vlt_flags {
$param{make_main} && $param{verilator_make_gmake};
unshift @verilator_flags, "../" . $self->{main_filename} if
$param{make_main} && $param{verilator_make_gmake};
if (defined $opt_optimize) {
my $letters = "";
if ($opt_optimize =~ /[a-zA-Z]/) {
$letters = $opt_optimize;
} else { # Randomly turn on/off different optimizations
foreach my $l ('a' .. 'z') {
$letters .= ((rand() > 0.5) ? $l : uc $l);
}
unshift @verilator_flags, "--trace" if rand() > 0.5;
unshift @verilator_flags, "--coverage" if rand() > 0.5;
}
unshift @verilator_flags, "--O" . $letters;
}
my @cmdargs = (
"--prefix " . $param{VM_PREFIX},
@ -2906,11 +2891,6 @@ Displays this message and program version and exits.
Run number of parallel tests, or 0 to determine the count based on the
number of cores installed. Requires Perl's Parallel::Forker package.
=item --optimize
Randomly turn on/off different optimizations. With specific flags,
use those optimization settings
=item --quiet
Suppress all output except for failures and progress messages every 15

View File

@ -15,7 +15,7 @@ top_filename("t/t_altera_lpm.v");
$module =~ s/_noinl//;
compile(
verilator_flags2 => ["--top-module ${module}", "-Oi"]
verilator_flags2 => ["--top-module ${module}", "-fno-inline"]
);
ok(1);

View File

@ -12,7 +12,7 @@ scenarios(vlt_all => 1);
top_filename("t/t_alw_reorder.v");
compile(
verilator_flags2 => ["--stats -Or"],
verilator_flags2 => ["--stats -fno-reorder"],
);
file_grep($Self->{stats}, qr/Optimizations, Split always\s+(\d+)/i, 0);

View File

@ -11,7 +11,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(simulator => 1);
compile(
verilator_flags2 => ["-O0 -OG"],
verilator_flags2 => ["-O0 -fgate"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t_assign_slice_overflow.v");
compile(
verilator_flags2 => ["-Ox"],
verilator_flags2 => ["-fno-expand"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(vlt => 1);
top_filename("t/t_case_66bits.v");
compile(
verilator_flags2 => ['-Ox'],
verilator_flags2 => ['-fno-expand'],
);
execute(

View File

@ -11,7 +11,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(simulator => 1);
compile(
verilator_flags2 => ["--trace --Os -x-assign 0"],
verilator_flags2 => ["--trace --fno-split -x-assign 0"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(vlt => 1);
top_filename("t/t_case_write1.v");
compile(
verilator_flags2 => ['-Ox'],
verilator_flags2 => ['-fno-expand'],
);
execute(

View File

@ -13,7 +13,7 @@ top_filename("t/t_const_opt.v");
# Run the same design as t_const_opt.pl without bitopt tree optimization to make sure that the result is same.
compile(
verilator_flags2 => ["-Wno-UNOPTTHREADS", "--stats", "-Oo", "$Self->{t_dir}/t_const_opt.cpp"],
verilator_flags2 => ["-Wno-UNOPTTHREADS", "--stats", "-fno-const-bit-op-tree", "$Self->{t_dir}/t_const_opt.cpp"],
);
execute(

View File

@ -11,7 +11,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(simulator => 1);
compile(
verilator_flags2 => ['--Ox'],
verilator_flags2 => ['--fno-expand'],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(vlt => 1);
top_filename("t/t_func_twocall.v");
compile(
verilator_flags2 => ['-Ox'],
verilator_flags2 => ['-fno-expand'],
);
execute(

View File

@ -16,7 +16,7 @@ scenarios(simulator => 1);
$Self->{sim_time} = 11000;
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -11,7 +11,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(simulator => 1);
compile(
verilator_flags2 => ["--Os -x-assign 0"],
verilator_flags2 => ["--fno-split -x-assign 0"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_inst_slice.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface1_modport.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface1.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface2.v");
compile(
verilator_flags2 => ["--top-module t -Oi"],
verilator_flags2 => ["--top-module t -fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_array2.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_array.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_down.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_gen10.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_gen11.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_gen12.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_gen2.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_gen3.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_gen4.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_gen5.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_gen6.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_gen7.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_gen8.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_gen9.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_gen.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -14,7 +14,7 @@ top_filename("t/t_interface.v");
compile(
# Avoid inlining so we find bugs in the non-inliner connection code
verilator_flags2 => ["-Oi"],
verilator_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_modport_import.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -14,7 +14,7 @@ top_filename("t/t_interface_modport.v");
compile(
# Avoid inlining so we find bugs in the non-inliner connection code
verilator_flags2 => ["-Oi"],
verilator_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_modport.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_mp_func.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_nest.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_interface_twod.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(linter => 1);
top_filename("t/t_lint_setout_bad.v");
lint(
verilator_flags2 => ["--lint-only -Oi"],
verilator_flags2 => ["--lint-only -fno-inline"],
fails => 1,
expect_filename => $Self->{golden_filename},
);

View File

@ -13,7 +13,7 @@ scenarios(vlt => 1);
top_filename("t/t_math_cond_huge.v");
compile(
verilator_flags2 => ['-Ox'],
verilator_flags2 => ['-fno-expand'],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(vlt => 1);
top_filename("t/t_math_div.v");
compile(
verilator_flags2 => ['-Ox'],
verilator_flags2 => ['-fno-expand'],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(vlt => 1);
top_filename("t/t_math_eq.v");
compile(
verilator_flags2 => ['-Ox'],
verilator_flags2 => ['-fno-expand'],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(vlt => 1);
top_filename("t/t_math_red.v");
compile(
verilator_flags2 => ['-Ox'],
verilator_flags2 => ['-fno-expand'],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(vlt => 1);
top_filename("t/t_math_shift.v");
compile(
verilator_flags2 => ["-Wno-CLKDATA", '-Ox'],
verilator_flags2 => ["-Wno-CLKDATA", '-fno-expand'],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(vlt => 1);
top_filename("t/t_math_signed.v");
compile(
verilator_flags2 => ['-Ox'],
verilator_flags2 => ['-fno-expand'],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(vlt => 1);
top_filename("t/t_math_vliw.v");
compile(
verilator_flags2 => ['-Ox'],
verilator_flags2 => ['-fno-expand'],
);
execute(

View File

@ -12,7 +12,7 @@ scenarios(simulator => 1);
compile(
# Disable inlining, this test is trivial without it
verilator_flags2 => ["-Oi --trace"],
verilator_flags2 => ["-fno-inline --trace"],
verilator_flags3 => [],
);

View File

@ -15,7 +15,7 @@ top_filename("t/t_mem_multi_io2.v");
compile(
make_top_shell => 0,
make_main => 0,
verilator_flags2 => ["--exe $Self->{t_dir}/t_mem_multi_io2.cpp -Oi"],
verilator_flags2 => ["--exe $Self->{t_dir}/t_mem_multi_io2.cpp -fno-inline"],
verilator_flags3 => [],
);

View File

@ -15,7 +15,7 @@ top_filename("t/t_mem_multi_io2.v");
compile(
make_top_shell => 0,
make_main => 0,
verilator_flags2 => ["--exe $Self->{t_dir}/t_mem_multi_io2.cpp --sc -Oi"],
verilator_flags2 => ["--exe $Self->{t_dir}/t_mem_multi_io2.cpp --sc -fno-inline"],
);
execute(

View File

@ -15,7 +15,7 @@ top_filename("t/t_mem_multi_io3.v");
compile(
make_top_shell => 0,
make_main => 0,
verilator_flags2 => ["--exe $Self->{t_dir}/t_mem_multi_io3.cpp -Oi"],
verilator_flags2 => ["--exe $Self->{t_dir}/t_mem_multi_io3.cpp -fno-inline"],
verilator_flags3 => [],
);

View File

@ -15,7 +15,7 @@ top_filename("t/t_mem_multi_io3.v");
compile(
make_top_shell => 0,
make_main => 0,
verilator_flags2 => ["--exe $Self->{t_dir}/t_mem_multi_io3.cpp --sc -Oi"],
verilator_flags2 => ["--exe $Self->{t_dir}/t_mem_multi_io3.cpp --sc -fno-inline"],
verilator_flags3 => [],
);

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_mem_multidim.v");
compile(
verilator_flags2 => ['--Ox'],
verilator_flags2 => ['--fno-expand'],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(vlt => 1);
top_filename("t/t_mem_packed.v");
compile(
verilator_flags2 => ['-Ox'],
verilator_flags2 => ['-fno-expand'],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_mod_interface_array0.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_mod_interface_array1.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_mod_interface_array2.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_mod_interface_array4.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -13,7 +13,7 @@ scenarios(simulator => 1);
top_filename("t/t_mod_interface_array6.v");
compile(
v_flags2 => ["-Oi"],
v_flags2 => ["-fno-inline"],
);
execute(

View File

@ -11,7 +11,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(vlt => 1);
compile(
verilator_flags2 => ['--stats', "-Ow"],
verilator_flags2 => ['--stats', "-fno-merge-cond"],
);
if ($Self->{vlt_all}) {

View File

@ -13,7 +13,7 @@ scenarios(vlt => 1);
top_filename("t/t_var_assign_landr.v");
compile(
verilator_flags2 => ['-Ox'],
verilator_flags2 => ['-fno-expand'],
);
execute(