forked from github/verilator
V3Simulate/V3Table: change deques to vectors for performance
We can get away with only push_back and back on sequence containers, in which case std::vector is significantly faster than std::deque.
This commit is contained in:
parent
fb56f4f880
commit
2a7aa28b20
@ -42,6 +42,7 @@
|
||||
|
||||
#include <deque>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
//============================================================================
|
||||
|
||||
@ -104,12 +105,12 @@ private:
|
||||
// Simulating:
|
||||
ConstPile m_constFreeps; ///< List of all AstConst* free and not in use
|
||||
ConstPile m_constAllps; ///< List of all AstConst* free and in use
|
||||
std::deque<SimStackNode*> m_callStack; ///< Call stack for verbose error messages
|
||||
std::vector<SimStackNode*> m_callStack; ///< Call stack for verbose error messages
|
||||
|
||||
// Cleanup
|
||||
// V3Numbers that represents strings are a bit special and the API for
|
||||
// V3Number does not allow changing them.
|
||||
std::deque<AstNode*> m_reclaimValuesp; // List of allocated string numbers
|
||||
std::vector<AstNode*> m_reclaimValuesp; // List of allocated string numbers
|
||||
|
||||
// Note level 8&9 include debugging each simulation value
|
||||
VL_DEBUG_FUNC; // Declare debug()
|
||||
@ -180,8 +181,7 @@ public:
|
||||
}
|
||||
m_whyNotOptimizable = why;
|
||||
std::ostringstream stack;
|
||||
for (std::deque<SimStackNode*>::iterator it = m_callStack.begin();
|
||||
it != m_callStack.end(); ++it) {
|
||||
for (auto it = m_callStack.rbegin(); it != m_callStack.rend(); ++it) {
|
||||
AstFuncRef* funcp = (*it)->m_funcp;
|
||||
stack << "\n " << funcp->fileline() << "... Called from "
|
||||
<< funcp->prettyName() << "() with parameters:";
|
||||
@ -978,7 +978,7 @@ private:
|
||||
}
|
||||
}
|
||||
SimStackNode stackNode(nodep, &tconnects);
|
||||
m_callStack.push_front(&stackNode);
|
||||
m_callStack.push_back(&stackNode);
|
||||
// Clear output variable
|
||||
if (auto* const basicp = VN_CAST(funcp->fvarp(), Var)->basicp()) {
|
||||
AstConst cnst(funcp->fvarp()->fileline(), AstConst::WidthedValue(), basicp->widthMin(),
|
||||
@ -992,7 +992,7 @@ private:
|
||||
}
|
||||
// Evaluate the function
|
||||
iterate(funcp);
|
||||
m_callStack.pop_front();
|
||||
m_callStack.pop_back();
|
||||
if (!m_checkOnly && optimizable()) {
|
||||
// Grab return value from output variable (if it's a function)
|
||||
UASSERT_OBJ(funcp->fvarp(), nodep, "Function reference points at non-function");
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "V3Ast.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
|
||||
//######################################################################
|
||||
// Table class functions
|
||||
@ -156,7 +156,6 @@ private:
|
||||
// State cleared on each module
|
||||
AstNodeModule* m_modp = nullptr; // Current MODULE
|
||||
int m_modTables = 0; // Number of tables created in this module
|
||||
std::deque<AstVarScope*> m_modTableVscs; // All tables created
|
||||
|
||||
// State cleared on each scope
|
||||
AstScope* m_scopep = nullptr; // Current SCOPE
|
||||
@ -165,7 +164,7 @@ private:
|
||||
bool m_assignDly = false; // Consists of delayed assignments instead of normal assignments
|
||||
unsigned m_inWidthBits = 0; // Input table width - in bits
|
||||
unsigned m_outWidthBytes = 0; // Output table width - in bytes
|
||||
std::deque<AstVarScope*> m_inVarps; // Input variable list
|
||||
std::vector<AstVarScope*> m_inVarps; // Input variable list
|
||||
std::vector<TableOutputVar> m_outVarps; // Output variable list
|
||||
|
||||
// METHODS
|
||||
@ -380,11 +379,9 @@ private:
|
||||
virtual void visit(AstNodeModule* nodep) override {
|
||||
VL_RESTORER(m_modp);
|
||||
VL_RESTORER(m_modTables);
|
||||
VL_RESTORER(m_modTableVscs);
|
||||
{
|
||||
m_modp = nodep;
|
||||
m_modTables = 0;
|
||||
m_modTableVscs.clear();
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user