forked from github/verilator
Internals: Use VNVisitorConst where possible, for better performance. No functional change indended.
This commit is contained in:
parent
82e653a739
commit
f2aac8c49a
@ -309,7 +309,7 @@ AstActive*& ActiveNamer::getSpecialActive<AstSenItem::Combo>() {
|
|||||||
//######################################################################
|
//######################################################################
|
||||||
// Latch checking visitor
|
// Latch checking visitor
|
||||||
|
|
||||||
class ActiveLatchCheckVisitor final : public VNVisitor {
|
class ActiveLatchCheckVisitor final : public VNVisitorConst {
|
||||||
private:
|
private:
|
||||||
// NODE STATE
|
// NODE STATE
|
||||||
// Input:
|
// Input:
|
||||||
@ -329,20 +329,20 @@ private:
|
|||||||
LatchDetectGraphVertex* const parentp = m_graph.currentp();
|
LatchDetectGraphVertex* const parentp = m_graph.currentp();
|
||||||
LatchDetectGraphVertex* const branchp = m_graph.addPathVertex(parentp, "BRANCH", true);
|
LatchDetectGraphVertex* const branchp = m_graph.addPathVertex(parentp, "BRANCH", true);
|
||||||
m_graph.addPathVertex(branchp, "IF");
|
m_graph.addPathVertex(branchp, "IF");
|
||||||
iterateAndNextNull(nodep->thensp());
|
iterateAndNextConstNull(nodep->thensp());
|
||||||
m_graph.addPathVertex(branchp, "ELSE");
|
m_graph.addPathVertex(branchp, "ELSE");
|
||||||
iterateAndNextNull(nodep->elsesp());
|
iterateAndNextConstNull(nodep->elsesp());
|
||||||
m_graph.currentp(parentp);
|
m_graph.currentp(parentp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//--------------------
|
//--------------------
|
||||||
void visit(AstNode* nodep) override { iterateChildren(nodep); }
|
void visit(AstNode* nodep) override { iterateChildrenConst(nodep); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
ActiveLatchCheckVisitor(AstNode* nodep, bool expectLatch) {
|
ActiveLatchCheckVisitor(AstNode* nodep, bool expectLatch) {
|
||||||
m_graph.begin();
|
m_graph.begin();
|
||||||
iterate(nodep);
|
iterateConst(nodep);
|
||||||
m_graph.latchCheck(nodep, expectLatch);
|
m_graph.latchCheck(nodep, expectLatch);
|
||||||
}
|
}
|
||||||
~ActiveLatchCheckVisitor() override = default;
|
~ActiveLatchCheckVisitor() override = default;
|
||||||
|
@ -38,7 +38,7 @@ VL_DEFINE_DEBUG_FUNCTIONS;
|
|||||||
//######################################################################
|
//######################################################################
|
||||||
// Branch state, as a visitor of each AstNode
|
// Branch state, as a visitor of each AstNode
|
||||||
|
|
||||||
class BranchVisitor final : public VNVisitor {
|
class BranchVisitor final : public VNVisitorConst {
|
||||||
private:
|
private:
|
||||||
// NODE STATE
|
// NODE STATE
|
||||||
// Entire netlist:
|
// Entire netlist:
|
||||||
@ -71,12 +71,12 @@ private:
|
|||||||
{
|
{
|
||||||
// Do if
|
// Do if
|
||||||
reset();
|
reset();
|
||||||
iterateAndNextNull(nodep->thensp());
|
iterateAndNextConstNull(nodep->thensp());
|
||||||
const int ifLikely = m_likely;
|
const int ifLikely = m_likely;
|
||||||
const int ifUnlikely = m_unlikely;
|
const int ifUnlikely = m_unlikely;
|
||||||
// Do else
|
// Do else
|
||||||
reset();
|
reset();
|
||||||
iterateAndNextNull(nodep->elsesp());
|
iterateAndNextConstNull(nodep->elsesp());
|
||||||
const int elseLikely = m_likely;
|
const int elseLikely = m_likely;
|
||||||
const int elseUnlikely = m_unlikely;
|
const int elseUnlikely = m_unlikely;
|
||||||
// Compute
|
// Compute
|
||||||
@ -91,16 +91,16 @@ private:
|
|||||||
void visit(AstNodeCCall* nodep) override {
|
void visit(AstNodeCCall* nodep) override {
|
||||||
checkUnlikely(nodep);
|
checkUnlikely(nodep);
|
||||||
nodep->funcp()->user1Inc();
|
nodep->funcp()->user1Inc();
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstCFunc* nodep) override {
|
void visit(AstCFunc* nodep) override {
|
||||||
checkUnlikely(nodep);
|
checkUnlikely(nodep);
|
||||||
m_cfuncsp.push_back(nodep);
|
m_cfuncsp.push_back(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstNode* nodep) override {
|
void visit(AstNode* nodep) override {
|
||||||
checkUnlikely(nodep);
|
checkUnlikely(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
|
|
||||||
// METHODS
|
// METHODS
|
||||||
@ -114,7 +114,7 @@ public:
|
|||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
explicit BranchVisitor(AstNetlist* nodep) {
|
explicit BranchVisitor(AstNetlist* nodep) {
|
||||||
reset();
|
reset();
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
calc_tasks();
|
calc_tasks();
|
||||||
}
|
}
|
||||||
~BranchVisitor() override = default;
|
~BranchVisitor() override = default;
|
||||||
|
@ -53,7 +53,7 @@ VL_DEFINE_DEBUG_FUNCTIONS;
|
|||||||
|
|
||||||
//######################################################################
|
//######################################################################
|
||||||
|
|
||||||
class CaseLintVisitor final : public VNVisitor {
|
class CaseLintVisitor final : public VNVisitorConst {
|
||||||
private:
|
private:
|
||||||
const AstNodeCase* m_caseExprp
|
const AstNodeCase* m_caseExprp
|
||||||
= nullptr; // Under a CASE value node, if so the relevant case statement
|
= nullptr; // Under a CASE value node, if so the relevant case statement
|
||||||
@ -79,10 +79,10 @@ private:
|
|||||||
// Check for X/Z in non-casex statements
|
// Check for X/Z in non-casex statements
|
||||||
{
|
{
|
||||||
m_caseExprp = nodep;
|
m_caseExprp = nodep;
|
||||||
iterate(nodep->exprp());
|
iterateConst(nodep->exprp());
|
||||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||||
iterateAndNextNull(itemp->condsp());
|
iterateAndNextConstNull(itemp->condsp());
|
||||||
}
|
}
|
||||||
m_caseExprp = nullptr;
|
m_caseExprp = nullptr;
|
||||||
}
|
}
|
||||||
@ -108,11 +108,11 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void visit(AstNode* nodep) override { iterateChildren(nodep); }
|
void visit(AstNode* nodep) override { iterateChildrenConst(nodep); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
explicit CaseLintVisitor(AstNodeCase* nodep) { iterate(nodep); }
|
explicit CaseLintVisitor(AstNodeCase* nodep) { iterateConst(nodep); }
|
||||||
~CaseLintVisitor() override = default;
|
~CaseLintVisitor() override = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ static int countTrailingZeroes(uint64_t val) {
|
|||||||
// This visitor can be used in the post-expanded Ast from V3Expand, where the Ast satisfies:
|
// This visitor can be used in the post-expanded Ast from V3Expand, where the Ast satisfies:
|
||||||
// - Constants are 64 bit at most (because words are accessed via AstWordSel)
|
// - Constants are 64 bit at most (because words are accessed via AstWordSel)
|
||||||
// - Variables are scoped.
|
// - Variables are scoped.
|
||||||
class ConstBitOpTreeVisitor final : public VNVisitor {
|
class ConstBitOpTreeVisitor final : public VNVisitorConst {
|
||||||
// NODE STATE
|
// NODE STATE
|
||||||
// AstVarRef::user4u -> Base index of m_varInfos that points VarInfo
|
// AstVarRef::user4u -> Base index of m_varInfos that points VarInfo
|
||||||
// AstVarScope::user4u -> Same as AstVarRef::user4
|
// AstVarScope::user4u -> Same as AstVarRef::user4
|
||||||
@ -416,7 +416,7 @@ class ConstBitOpTreeVisitor final : public VNVisitor {
|
|||||||
{
|
{
|
||||||
VL_RESTORER(m_leafp);
|
VL_RESTORER(m_leafp);
|
||||||
m_leafp = &info;
|
m_leafp = &info;
|
||||||
iterate(nodep);
|
iterateConst(nodep);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok = !m_failed;
|
bool ok = !m_failed;
|
||||||
@ -431,7 +431,7 @@ class ConstBitOpTreeVisitor final : public VNVisitor {
|
|||||||
// VISITORS
|
// VISITORS
|
||||||
void visit(AstNode* nodep) override { CONST_BITOP_SET_FAILED("Hit unexpected op", nodep); }
|
void visit(AstNode* nodep) override { CONST_BITOP_SET_FAILED("Hit unexpected op", nodep); }
|
||||||
void visit(AstCCast* nodep) override {
|
void visit(AstCCast* nodep) override {
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
if (m_leafp) m_leafp->updateBitRange(nodep);
|
if (m_leafp) m_leafp->updateBitRange(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstShiftR* nodep) override {
|
void visit(AstShiftR* nodep) override {
|
||||||
@ -440,7 +440,7 @@ class ConstBitOpTreeVisitor final : public VNVisitor {
|
|||||||
CONST_BITOP_RETURN_IF(!constp, nodep->rhsp());
|
CONST_BITOP_RETURN_IF(!constp, nodep->rhsp());
|
||||||
m_lsb += constp->toUInt();
|
m_lsb += constp->toUInt();
|
||||||
incrOps(nodep, __LINE__);
|
incrOps(nodep, __LINE__);
|
||||||
iterate(nodep->lhsp());
|
iterateConst(nodep->lhsp());
|
||||||
m_leafp->updateBitRange(nodep);
|
m_leafp->updateBitRange(nodep);
|
||||||
m_lsb -= constp->toUInt();
|
m_lsb -= constp->toUInt();
|
||||||
}
|
}
|
||||||
@ -454,7 +454,7 @@ class ConstBitOpTreeVisitor final : public VNVisitor {
|
|||||||
lhsp);
|
lhsp);
|
||||||
incrOps(nodep, __LINE__);
|
incrOps(nodep, __LINE__);
|
||||||
m_polarity = !m_polarity;
|
m_polarity = !m_polarity;
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
// Don't restore m_polarity for Xor as it counts parity of the entire tree
|
// Don't restore m_polarity for Xor as it counts parity of the entire tree
|
||||||
if (!isXorTree()) m_polarity = !m_polarity;
|
if (!isXorTree()) m_polarity = !m_polarity;
|
||||||
if (m_leafp && castp) m_leafp->updateBitRange(castp);
|
if (m_leafp && castp) m_leafp->updateBitRange(castp);
|
||||||
@ -465,7 +465,7 @@ class ConstBitOpTreeVisitor final : public VNVisitor {
|
|||||||
CONST_BITOP_RETURN_IF(!constp, nodep->rhsp());
|
CONST_BITOP_RETURN_IF(!constp, nodep->rhsp());
|
||||||
UASSERT_OBJ(m_leafp->wordIdx() == -1, nodep, "Unexpected nested WordSel");
|
UASSERT_OBJ(m_leafp->wordIdx() == -1, nodep, "Unexpected nested WordSel");
|
||||||
m_leafp->wordIdx(constp->toSInt());
|
m_leafp->wordIdx(constp->toSInt());
|
||||||
iterate(nodep->fromp());
|
iterateConst(nodep->fromp());
|
||||||
}
|
}
|
||||||
void visit(AstVarRef* nodep) override {
|
void visit(AstVarRef* nodep) override {
|
||||||
CONST_BITOP_RETURN_IF(!m_leafp, nodep);
|
CONST_BITOP_RETURN_IF(!m_leafp, nodep);
|
||||||
@ -529,7 +529,7 @@ class ConstBitOpTreeVisitor final : public VNVisitor {
|
|||||||
// Always reach past a plain making AND
|
// Always reach past a plain making AND
|
||||||
Restorer restorer{*this};
|
Restorer restorer{*this};
|
||||||
incrOps(nodep, __LINE__);
|
incrOps(nodep, __LINE__);
|
||||||
iterate(nodep->rhsp());
|
iterateConst(nodep->rhsp());
|
||||||
CONST_BITOP_RETURN_IF(m_failed, nodep->rhsp());
|
CONST_BITOP_RETURN_IF(m_failed, nodep->rhsp());
|
||||||
restorer.disableRestore(); // Now all checks passed
|
restorer.disableRestore(); // Now all checks passed
|
||||||
} else if (nodep->type() == m_rootp->type()) { // And, Or, Xor
|
} else if (nodep->type() == m_rootp->type()) { // And, Or, Xor
|
||||||
@ -542,7 +542,7 @@ class ConstBitOpTreeVisitor final : public VNVisitor {
|
|||||||
m_leafp = &leafInfo;
|
m_leafp = &leafInfo;
|
||||||
AstNodeExpr* opp = right ? nodep->rhsp() : nodep->lhsp();
|
AstNodeExpr* opp = right ? nodep->rhsp() : nodep->lhsp();
|
||||||
const bool origFailed = m_failed;
|
const bool origFailed = m_failed;
|
||||||
iterate(opp);
|
iterateConst(opp);
|
||||||
if (leafInfo.constp() || m_failed) {
|
if (leafInfo.constp() || m_failed) {
|
||||||
// Revert changes in leaf
|
// Revert changes in leaf
|
||||||
restorer.restoreNow();
|
restorer.restoreNow();
|
||||||
@ -647,11 +647,11 @@ class ConstBitOpTreeVisitor final : public VNVisitor {
|
|||||||
m_varInfos.push_back(nullptr);
|
m_varInfos.push_back(nullptr);
|
||||||
CONST_BITOP_RETURN_IF(!isAndTree() && !isOrTree() && !isXorTree(), nodep);
|
CONST_BITOP_RETURN_IF(!isAndTree() && !isOrTree() && !isXorTree(), nodep);
|
||||||
if (AstNodeBiop* const biopp = VN_CAST(nodep, NodeBiop)) {
|
if (AstNodeBiop* const biopp = VN_CAST(nodep, NodeBiop)) {
|
||||||
iterate(biopp);
|
iterateConst(biopp);
|
||||||
} else {
|
} else {
|
||||||
UASSERT_OBJ(VN_IS(nodep, RedXor), nodep, "Must be RedXor");
|
UASSERT_OBJ(VN_IS(nodep, RedXor), nodep, "Must be RedXor");
|
||||||
incrOps(nodep, __LINE__);
|
incrOps(nodep, __LINE__);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
for (auto&& entry : m_bitPolarities) {
|
for (auto&& entry : m_bitPolarities) {
|
||||||
getVarInfo(entry.m_info).setPolarity(entry.m_polarity, entry.m_bit);
|
getVarInfo(entry.m_info).setPolarity(entry.m_polarity, entry.m_bit);
|
||||||
|
@ -39,7 +39,7 @@ EmitCParentModule::EmitCParentModule() {
|
|||||||
//######################################################################
|
//######################################################################
|
||||||
// EmitCBaseVisitor implementation
|
// EmitCBaseVisitor implementation
|
||||||
|
|
||||||
string EmitCBaseVisitor::funcNameProtect(const AstCFunc* nodep, const AstNodeModule* modp) {
|
string EmitCBaseVisitorConst::funcNameProtect(const AstCFunc* nodep, const AstNodeModule* modp) {
|
||||||
modp = modp ? modp : EmitCParentModule::get(nodep);
|
modp = modp ? modp : EmitCParentModule::get(nodep);
|
||||||
string name;
|
string name;
|
||||||
if (nodep->isConstructor()) {
|
if (nodep->isConstructor()) {
|
||||||
@ -57,7 +57,8 @@ string EmitCBaseVisitor::funcNameProtect(const AstCFunc* nodep, const AstNodeMod
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstCFile* EmitCBaseVisitor::newCFile(const string& filename, bool slow, bool source, bool add) {
|
AstCFile* EmitCBaseVisitorConst::newCFile(const string& filename, bool slow, bool source,
|
||||||
|
bool add) {
|
||||||
AstCFile* const cfilep = new AstCFile{v3Global.rootp()->fileline(), filename};
|
AstCFile* const cfilep = new AstCFile{v3Global.rootp()->fileline(), filename};
|
||||||
cfilep->slow(slow);
|
cfilep->slow(slow);
|
||||||
cfilep->source(source);
|
cfilep->source(source);
|
||||||
@ -65,7 +66,7 @@ AstCFile* EmitCBaseVisitor::newCFile(const string& filename, bool slow, bool sou
|
|||||||
return cfilep;
|
return cfilep;
|
||||||
}
|
}
|
||||||
|
|
||||||
string EmitCBaseVisitor::cFuncArgs(const AstCFunc* nodep) {
|
string EmitCBaseVisitorConst::cFuncArgs(const AstCFunc* nodep) {
|
||||||
// Return argument list for given C function
|
// Return argument list for given C function
|
||||||
string args;
|
string args;
|
||||||
if (nodep->isLoose() && !nodep->isStatic()) {
|
if (nodep->isLoose() && !nodep->isStatic()) {
|
||||||
@ -95,8 +96,8 @@ string EmitCBaseVisitor::cFuncArgs(const AstCFunc* nodep) {
|
|||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitCBaseVisitor::emitCFuncHeader(const AstCFunc* funcp, const AstNodeModule* modp,
|
void EmitCBaseVisitorConst::emitCFuncHeader(const AstCFunc* funcp, const AstNodeModule* modp,
|
||||||
bool withScope) {
|
bool withScope) {
|
||||||
if (funcp->slow()) puts("VL_ATTR_COLD ");
|
if (funcp->slow()) puts("VL_ATTR_COLD ");
|
||||||
if (!funcp->isConstructor() && !funcp->isDestructor()) {
|
if (!funcp->isConstructor() && !funcp->isDestructor()) {
|
||||||
puts(funcp->rtnTypeVoid());
|
puts(funcp->rtnTypeVoid());
|
||||||
@ -114,8 +115,8 @@ void EmitCBaseVisitor::emitCFuncHeader(const AstCFunc* funcp, const AstNodeModul
|
|||||||
if (funcp->isConst().trueKnown() && funcp->isProperMethod()) puts(" const");
|
if (funcp->isConst().trueKnown() && funcp->isProperMethod()) puts(" const");
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitCBaseVisitor::emitCFuncDecl(const AstCFunc* funcp, const AstNodeModule* modp,
|
void EmitCBaseVisitorConst::emitCFuncDecl(const AstCFunc* funcp, const AstNodeModule* modp,
|
||||||
bool cLinkage) {
|
bool cLinkage) {
|
||||||
ensureNewLine();
|
ensureNewLine();
|
||||||
if (!funcp->ifdef().empty()) puts("#ifdef " + funcp->ifdef() + "\n");
|
if (!funcp->ifdef().empty()) puts("#ifdef " + funcp->ifdef() + "\n");
|
||||||
if (cLinkage) puts("extern \"C\" ");
|
if (cLinkage) puts("extern \"C\" ");
|
||||||
@ -129,7 +130,7 @@ void EmitCBaseVisitor::emitCFuncDecl(const AstCFunc* funcp, const AstNodeModule*
|
|||||||
if (!funcp->ifdef().empty()) puts("#endif // " + funcp->ifdef() + "\n");
|
if (!funcp->ifdef().empty()) puts("#endif // " + funcp->ifdef() + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitCBaseVisitor::emitVarDecl(const AstVar* nodep, bool asRef) {
|
void EmitCBaseVisitorConst::emitVarDecl(const AstVar* nodep, bool asRef) {
|
||||||
const AstBasicDType* const basicp = nodep->basicp();
|
const AstBasicDType* const basicp = nodep->basicp();
|
||||||
bool refNeedParens = VN_IS(nodep->dtypeSkipRefp(), UnpackArrayDType);
|
bool refNeedParens = VN_IS(nodep->dtypeSkipRefp(), UnpackArrayDType);
|
||||||
|
|
||||||
@ -217,7 +218,7 @@ void EmitCBaseVisitor::emitVarDecl(const AstVar* nodep, bool asRef) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitCBaseVisitor::emitModCUse(const AstNodeModule* modp, VUseType useType) {
|
void EmitCBaseVisitorConst::emitModCUse(const AstNodeModule* modp, VUseType useType) {
|
||||||
string nl;
|
string nl;
|
||||||
for (AstNode* itemp = modp->stmtsp(); itemp; itemp = itemp->nextp()) {
|
for (AstNode* itemp = modp->stmtsp(); itemp; itemp = itemp->nextp()) {
|
||||||
if (AstCUse* const usep = VN_CAST(itemp, CUse)) {
|
if (AstCUse* const usep = VN_CAST(itemp, CUse)) {
|
||||||
@ -235,7 +236,7 @@ void EmitCBaseVisitor::emitModCUse(const AstNodeModule* modp, VUseType useType)
|
|||||||
puts(nl);
|
puts(nl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitCBaseVisitor::emitTextSection(const AstNodeModule* modp, VNType type) {
|
void EmitCBaseVisitorConst::emitTextSection(const AstNodeModule* modp, VNType type) {
|
||||||
// Short circuit if nothing to do. This can save a lot of time on large designs as this
|
// Short circuit if nothing to do. This can save a lot of time on large designs as this
|
||||||
// function needs to traverse the entire module linearly.
|
// function needs to traverse the entire module linearly.
|
||||||
if (!v3Global.hasSCTextSections()) return;
|
if (!v3Global.hasSCTextSections()) return;
|
||||||
|
@ -77,7 +77,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class EmitCBaseVisitor VL_NOT_FINAL : public VNVisitor, public EmitCBase {
|
class EmitCBaseVisitorConst VL_NOT_FINAL : public VNVisitorConst, public EmitCBase {
|
||||||
public:
|
public:
|
||||||
// STATE
|
// STATE
|
||||||
V3OutCFile* m_ofp = nullptr;
|
V3OutCFile* m_ofp = nullptr;
|
||||||
@ -115,8 +115,8 @@ public:
|
|||||||
void emitTextSection(const AstNodeModule* modp, VNType type);
|
void emitTextSection(const AstNodeModule* modp, VNType type);
|
||||||
|
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
EmitCBaseVisitor() = default;
|
EmitCBaseVisitorConst() = default;
|
||||||
~EmitCBaseVisitor() override = default;
|
~EmitCBaseVisitorConst() override = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
//######################################################################
|
//######################################################################
|
||||||
// Emitter that can emit constant initializer expressions
|
// Emitter that can emit constant initializer expressions
|
||||||
|
|
||||||
class EmitCConstInit VL_NOT_FINAL : public EmitCBaseVisitor {
|
class EmitCConstInit VL_NOT_FINAL : public EmitCBaseVisitorConst {
|
||||||
// MEMBERS
|
// MEMBERS
|
||||||
uint32_t m_unpackedWord = 0;
|
uint32_t m_unpackedWord = 0;
|
||||||
bool m_inUnpacked = false;
|
bool m_inUnpacked = false;
|
||||||
@ -64,7 +64,7 @@ protected:
|
|||||||
ofp()->printf("%" PRIx64 "ULL", itr.first);
|
ofp()->printf("%" PRIx64 "ULL", itr.first);
|
||||||
ofp()->putsNoTracking(":");
|
ofp()->putsNoTracking(":");
|
||||||
ofp()->putsNoTracking("{");
|
ofp()->putsNoTracking("{");
|
||||||
iterate(nodep->getIndexValuep(itr.first));
|
iterateConst(nodep->getIndexValuep(itr.first));
|
||||||
ofp()->putsNoTracking("}");
|
ofp()->putsNoTracking("}");
|
||||||
}
|
}
|
||||||
puts("\n");
|
puts("\n");
|
||||||
@ -83,7 +83,7 @@ protected:
|
|||||||
for (uint64_t n = 0; n < size; ++n) {
|
for (uint64_t n = 0; n < size; ++n) {
|
||||||
m_unpackedWord = n;
|
m_unpackedWord = n;
|
||||||
if (n) puts((n % tabMod) ? ", " : ",\n");
|
if (n) puts((n % tabMod) ? ", " : ",\n");
|
||||||
iterate(nodep->getIndexDefaultedValuep(n));
|
iterateConst(nodep->getIndexDefaultedValuep(n));
|
||||||
}
|
}
|
||||||
puts("\n");
|
puts("\n");
|
||||||
puts("}");
|
puts("}");
|
||||||
|
@ -87,7 +87,7 @@ class EmitCConstPool final : public EmitCConstInit {
|
|||||||
puts("extern const ");
|
puts("extern const ");
|
||||||
puts(varp->dtypep()->cType(nameProtect, false, false));
|
puts(varp->dtypep()->cType(nameProtect, false, false));
|
||||||
puts(" = ");
|
puts(" = ");
|
||||||
iterate(varp->valuep());
|
iterateConst(varp->valuep());
|
||||||
puts(";\n");
|
puts(";\n");
|
||||||
// Keep track of stats
|
// Keep track of stats
|
||||||
if (VN_IS(varp->dtypep(), UnpackArrayDType)) {
|
if (VN_IS(varp->dtypep(), UnpackArrayDType)) {
|
||||||
|
@ -138,7 +138,7 @@ void EmitCFunc::emitOpName(AstNode* nodep, const string& format, AstNode* lhsp,
|
|||||||
case 'i':
|
case 'i':
|
||||||
COMMA;
|
COMMA;
|
||||||
UASSERT_OBJ(detailp, nodep, "emitOperator() references undef node");
|
UASSERT_OBJ(detailp, nodep, "emitOperator() references undef node");
|
||||||
iterateAndNextNull(detailp);
|
iterateAndNextConstNull(detailp);
|
||||||
needComma = true;
|
needComma = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -174,7 +174,7 @@ void EmitCFunc::displayEmit(AstNode* nodep, bool isScan) {
|
|||||||
if (const AstFScanF* const dispp = VN_CAST(nodep, FScanF)) {
|
if (const AstFScanF* const dispp = VN_CAST(nodep, FScanF)) {
|
||||||
isStmt = false;
|
isStmt = false;
|
||||||
puts("VL_FSCANF_IX(");
|
puts("VL_FSCANF_IX(");
|
||||||
iterate(dispp->filep());
|
iterateConst(dispp->filep());
|
||||||
puts(",");
|
puts(",");
|
||||||
} else if (const AstSScanF* const dispp = VN_CAST(nodep, SScanF)) {
|
} else if (const AstSScanF* const dispp = VN_CAST(nodep, SScanF)) {
|
||||||
isStmt = false;
|
isStmt = false;
|
||||||
@ -184,13 +184,13 @@ void EmitCFunc::displayEmit(AstNode* nodep, bool isScan) {
|
|||||||
puts("X(");
|
puts("X(");
|
||||||
puts(cvtToStr(dispp->fromp()->widthMin()));
|
puts(cvtToStr(dispp->fromp()->widthMin()));
|
||||||
puts(",");
|
puts(",");
|
||||||
iterate(dispp->fromp());
|
iterateConst(dispp->fromp());
|
||||||
puts(",");
|
puts(",");
|
||||||
} else if (const AstDisplay* const dispp = VN_CAST(nodep, Display)) {
|
} else if (const AstDisplay* const dispp = VN_CAST(nodep, Display)) {
|
||||||
isStmt = true;
|
isStmt = true;
|
||||||
if (dispp->filep()) {
|
if (dispp->filep()) {
|
||||||
puts("VL_FWRITEF(");
|
puts("VL_FWRITEF(");
|
||||||
iterate(dispp->filep());
|
iterateConst(dispp->filep());
|
||||||
puts(",");
|
puts(",");
|
||||||
} else {
|
} else {
|
||||||
puts("VL_WRITEF(");
|
puts("VL_WRITEF(");
|
||||||
@ -200,7 +200,7 @@ void EmitCFunc::displayEmit(AstNode* nodep, bool isScan) {
|
|||||||
puts("VL_SFORMAT_X(");
|
puts("VL_SFORMAT_X(");
|
||||||
puts(cvtToStr(dispp->lhsp()->widthMin()));
|
puts(cvtToStr(dispp->lhsp()->widthMin()));
|
||||||
putbs(",");
|
putbs(",");
|
||||||
iterate(dispp->lhsp());
|
iterateConst(dispp->lhsp());
|
||||||
putbs(",");
|
putbs(",");
|
||||||
} else if (VN_IS(nodep, SFormatF)) {
|
} else if (VN_IS(nodep, SFormatF)) {
|
||||||
isStmt = false;
|
isStmt = false;
|
||||||
@ -223,7 +223,7 @@ void EmitCFunc::displayEmit(AstNode* nodep, bool isScan) {
|
|||||||
} else if (argp) {
|
} else if (argp) {
|
||||||
const bool addrof = isScan || (fmt == '@');
|
const bool addrof = isScan || (fmt == '@');
|
||||||
if (addrof) puts("&(");
|
if (addrof) puts("&(");
|
||||||
iterate(argp);
|
iterateConst(argp);
|
||||||
if (!addrof) emitDatap(argp);
|
if (!addrof) emitDatap(argp);
|
||||||
if (addrof) puts(")");
|
if (addrof) puts(")");
|
||||||
}
|
}
|
||||||
@ -452,16 +452,16 @@ void EmitCFunc::emitCvtPackStr(AstNode* nodep) {
|
|||||||
puts(cvtToStr(nodep->widthWords()));
|
puts(cvtToStr(nodep->widthWords()));
|
||||||
puts(", ");
|
puts(", ");
|
||||||
}
|
}
|
||||||
iterateAndNextNull(nodep);
|
iterateAndNextConstNull(nodep);
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitCFunc::emitCvtWideArray(AstNode* nodep, AstNode* fromp) {
|
void EmitCFunc::emitCvtWideArray(AstNode* nodep, AstNode* fromp) {
|
||||||
putbs("VL_CVT_W_A(");
|
putbs("VL_CVT_W_A(");
|
||||||
iterate(nodep);
|
iterateConst(nodep);
|
||||||
puts(", ");
|
puts(", ");
|
||||||
iterate(fromp);
|
iterateConst(fromp);
|
||||||
putbs(".atDefault()"); // Not accessed; only to get the proper type of values
|
putbs(".atDefault()"); // Not accessed; only to get the proper type of values
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ class EmitCLazyDecls final : public VNVisitorConst {
|
|||||||
|
|
||||||
// MEMBERS
|
// MEMBERS
|
||||||
std::unordered_set<string> m_emittedManually; // Set of names already declared manually.
|
std::unordered_set<string> m_emittedManually; // Set of names already declared manually.
|
||||||
EmitCBaseVisitor& m_emitter; // For access to file output
|
EmitCBaseVisitorConst& m_emitter; // For access to file output
|
||||||
bool m_needsBlankLine = false; // Emit blank line if any declarations were emitted (cosmetic)
|
bool m_needsBlankLine = false; // Emit blank line if any declarations were emitted (cosmetic)
|
||||||
std::set<AstNode*> m_emitted; // -> in set. Already emitted decl for symbols.
|
std::set<AstNode*> m_emitted; // -> in set. Already emitted decl for symbols.
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ class EmitCLazyDecls final : public VNVisitorConst {
|
|||||||
void visit(AstNode* nodep) override { iterateChildrenConst(nodep); }
|
void visit(AstNode* nodep) override { iterateChildrenConst(nodep); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EmitCLazyDecls(EmitCBaseVisitor& emitter)
|
explicit EmitCLazyDecls(EmitCBaseVisitorConst& emitter)
|
||||||
: m_emitter(emitter) {}
|
: m_emitter(emitter) {}
|
||||||
void emit(AstNode* nodep) {
|
void emit(AstNode* nodep) {
|
||||||
m_needsBlankLine = false;
|
m_needsBlankLine = false;
|
||||||
@ -203,12 +203,12 @@ public:
|
|||||||
// variables. That way we could just invoke the appropriate emitter as needed.
|
// variables. That way we could just invoke the appropriate emitter as needed.
|
||||||
VL_RESTORER(m_emitConstInit);
|
VL_RESTORER(m_emitConstInit);
|
||||||
m_emitConstInit = true;
|
m_emitConstInit = true;
|
||||||
iterate(initp);
|
iterateConst(initp);
|
||||||
}
|
}
|
||||||
void putCommaIterateNext(AstNode* nodep, bool comma = false) {
|
void putCommaIterateNext(AstNode* nodep, bool comma = false) {
|
||||||
for (AstNode* subnodep = nodep; subnodep; subnodep = subnodep->nextp()) {
|
for (AstNode* subnodep = nodep; subnodep; subnodep = subnodep->nextp()) {
|
||||||
if (comma) puts(", ");
|
if (comma) puts(", ");
|
||||||
iterate(subnodep);
|
iterateConst(subnodep);
|
||||||
comma = true;
|
comma = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -273,17 +273,17 @@ public:
|
|||||||
|
|
||||||
if (nodep->initsp()) {
|
if (nodep->initsp()) {
|
||||||
putsDecoration("// Init\n");
|
putsDecoration("// Init\n");
|
||||||
iterateAndNextNull(nodep->initsp());
|
iterateAndNextConstNull(nodep->initsp());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodep->stmtsp()) {
|
if (nodep->stmtsp()) {
|
||||||
putsDecoration("// Body\n");
|
putsDecoration("// Body\n");
|
||||||
iterateAndNextNull(nodep->stmtsp());
|
iterateAndNextConstNull(nodep->stmtsp());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodep->finalsp()) {
|
if (nodep->finalsp()) {
|
||||||
putsDecoration("// Final\n");
|
putsDecoration("// Final\n");
|
||||||
iterateAndNextNull(nodep->finalsp());
|
iterateAndNextConstNull(nodep->finalsp());
|
||||||
}
|
}
|
||||||
|
|
||||||
puts("}\n");
|
puts("}\n");
|
||||||
@ -309,9 +309,9 @@ public:
|
|||||||
} else {
|
} else {
|
||||||
puts("I(");
|
puts("I(");
|
||||||
}
|
}
|
||||||
iterateAndNextNull(selp->lsbp());
|
iterateAndNextConstNull(selp->lsbp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
iterateAndNextNull(selp->fromp());
|
iterateAndNextConstNull(selp->fromp());
|
||||||
if (rhs) puts(", ");
|
if (rhs) puts(", ");
|
||||||
} else {
|
} else {
|
||||||
putbs("VL_ASSIGNSEL_");
|
putbs("VL_ASSIGNSEL_");
|
||||||
@ -320,18 +320,18 @@ public:
|
|||||||
puts("(");
|
puts("(");
|
||||||
puts(cvtToStr(selp->fromp()->widthMin()) + ",");
|
puts(cvtToStr(selp->fromp()->widthMin()) + ",");
|
||||||
puts(cvtToStr(nodep->widthMin()) + ",");
|
puts(cvtToStr(nodep->widthMin()) + ",");
|
||||||
iterateAndNextNull(selp->lsbp());
|
iterateAndNextConstNull(selp->lsbp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
iterateAndNextNull(selp->fromp());
|
iterateAndNextConstNull(selp->fromp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
}
|
}
|
||||||
} else if (const AstGetcRefN* const selp = VN_CAST(nodep->lhsp(), GetcRefN)) {
|
} else if (const AstGetcRefN* const selp = VN_CAST(nodep->lhsp(), GetcRefN)) {
|
||||||
iterateAndNextNull(selp->lhsp());
|
iterateAndNextConstNull(selp->lhsp());
|
||||||
puts(" = ");
|
puts(" = ");
|
||||||
putbs("VL_PUTC_N(");
|
putbs("VL_PUTC_N(");
|
||||||
iterateAndNextNull(selp->lhsp());
|
iterateAndNextConstNull(selp->lhsp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
iterateAndNextNull(selp->rhsp());
|
iterateAndNextConstNull(selp->rhsp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
} else if (AstVar* const varp = AstVar::scVarRecurse(nodep->lhsp())) {
|
} else if (AstVar* const varp = AstVar::scVarRecurse(nodep->lhsp())) {
|
||||||
putbs("VL_ASSIGN_"); // Set a systemC variable
|
putbs("VL_ASSIGN_"); // Set a systemC variable
|
||||||
@ -339,7 +339,7 @@ public:
|
|||||||
emitIQW(nodep);
|
emitIQW(nodep);
|
||||||
puts("(");
|
puts("(");
|
||||||
puts(cvtToStr(nodep->widthMin()) + ",");
|
puts(cvtToStr(nodep->widthMin()) + ",");
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
} else if (AstVar* const varp = AstVar::scVarRecurse(nodep->rhsp())) {
|
} else if (AstVar* const varp = AstVar::scVarRecurse(nodep->rhsp())) {
|
||||||
putbs("VL_ASSIGN_"); // Get a systemC variable
|
putbs("VL_ASSIGN_"); // Get a systemC variable
|
||||||
@ -347,7 +347,7 @@ public:
|
|||||||
emitScIQW(varp);
|
emitScIQW(varp);
|
||||||
puts("(");
|
puts("(");
|
||||||
puts(cvtToStr(nodep->widthMin()) + ",");
|
puts(cvtToStr(nodep->widthMin()) + ",");
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
} else if (nodep->isWide() && VN_IS(nodep->lhsp(), VarRef) //
|
} else if (nodep->isWide() && VN_IS(nodep->lhsp(), VarRef) //
|
||||||
&& !VN_IS(nodep->rhsp(), CExpr) //
|
&& !VN_IS(nodep->rhsp(), CExpr) //
|
||||||
@ -361,41 +361,41 @@ public:
|
|||||||
} else if (nodep->isWide() && !VN_IS(nodep->dtypep()->skipRefp(), UnpackArrayDType)) {
|
} else if (nodep->isWide() && !VN_IS(nodep->dtypep()->skipRefp(), UnpackArrayDType)) {
|
||||||
putbs("VL_ASSIGN_W(");
|
putbs("VL_ASSIGN_W(");
|
||||||
puts(cvtToStr(nodep->widthMin()) + ",");
|
puts(cvtToStr(nodep->widthMin()) + ",");
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
} else {
|
} else {
|
||||||
paren = false;
|
paren = false;
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
puts(" ");
|
puts(" ");
|
||||||
ofp()->blockInc();
|
ofp()->blockInc();
|
||||||
decind = true;
|
decind = true;
|
||||||
if (!VN_IS(nodep->rhsp(), Const)) ofp()->putBreak();
|
if (!VN_IS(nodep->rhsp(), Const)) ofp()->putBreak();
|
||||||
puts("= ");
|
puts("= ");
|
||||||
}
|
}
|
||||||
if (rhs) iterateAndNextNull(nodep->rhsp());
|
if (rhs) iterateAndNextConstNull(nodep->rhsp());
|
||||||
if (paren) puts(")");
|
if (paren) puts(")");
|
||||||
if (decind) ofp()->blockDec();
|
if (decind) ofp()->blockDec();
|
||||||
puts(";\n");
|
puts(";\n");
|
||||||
}
|
}
|
||||||
void visit(AstAlwaysPublic*) override {}
|
void visit(AstAlwaysPublic*) override {}
|
||||||
void visit(AstAssocSel* nodep) override {
|
void visit(AstAssocSel* nodep) override {
|
||||||
iterateAndNextNull(nodep->fromp());
|
iterateAndNextConstNull(nodep->fromp());
|
||||||
putbs(".at(");
|
putbs(".at(");
|
||||||
AstAssocArrayDType* const adtypep = VN_AS(nodep->fromp()->dtypep(), AssocArrayDType);
|
AstAssocArrayDType* const adtypep = VN_AS(nodep->fromp()->dtypep(), AssocArrayDType);
|
||||||
UASSERT_OBJ(adtypep, nodep, "Associative select on non-associative type");
|
UASSERT_OBJ(adtypep, nodep, "Associative select on non-associative type");
|
||||||
if (adtypep->keyDTypep()->isWide()) {
|
if (adtypep->keyDTypep()->isWide()) {
|
||||||
emitCvtWideArray(nodep->bitp(), nodep->fromp());
|
emitCvtWideArray(nodep->bitp(), nodep->fromp());
|
||||||
} else {
|
} else {
|
||||||
iterateAndNextNull(nodep->bitp());
|
iterateAndNextConstNull(nodep->bitp());
|
||||||
}
|
}
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
void visit(AstWildcardSel* nodep) override {
|
void visit(AstWildcardSel* nodep) override {
|
||||||
iterateAndNextNull(nodep->fromp());
|
iterateAndNextConstNull(nodep->fromp());
|
||||||
putbs(".at(");
|
putbs(".at(");
|
||||||
AstWildcardArrayDType* const adtypep = VN_AS(nodep->fromp()->dtypep(), WildcardArrayDType);
|
AstWildcardArrayDType* const adtypep = VN_AS(nodep->fromp()->dtypep(), WildcardArrayDType);
|
||||||
UASSERT_OBJ(adtypep, nodep, "Wildcard select on non-wildcard-associative type");
|
UASSERT_OBJ(adtypep, nodep, "Wildcard select on non-wildcard-associative type");
|
||||||
iterateAndNextNull(nodep->bitp());
|
iterateAndNextConstNull(nodep->bitp());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
void visit(AstCCall* nodep) override {
|
void visit(AstCCall* nodep) override {
|
||||||
@ -427,14 +427,14 @@ public:
|
|||||||
void visit(AstCMethodCall* nodep) override {
|
void visit(AstCMethodCall* nodep) override {
|
||||||
const AstCFunc* const funcp = nodep->funcp();
|
const AstCFunc* const funcp = nodep->funcp();
|
||||||
UASSERT_OBJ(!funcp->isLoose(), nodep, "Loose method called via AstCMethodCall");
|
UASSERT_OBJ(!funcp->isLoose(), nodep, "Loose method called via AstCMethodCall");
|
||||||
iterate(nodep->fromp());
|
iterateConst(nodep->fromp());
|
||||||
putbs("->");
|
putbs("->");
|
||||||
puts(funcp->nameProtect());
|
puts(funcp->nameProtect());
|
||||||
emitCCallArgs(nodep, "");
|
emitCCallArgs(nodep, "");
|
||||||
}
|
}
|
||||||
void visit(AstCAwait* nodep) override {
|
void visit(AstCAwait* nodep) override {
|
||||||
puts("co_await ");
|
puts("co_await ");
|
||||||
iterate(nodep->exprp());
|
iterateConst(nodep->exprp());
|
||||||
}
|
}
|
||||||
void visit(AstCNew* nodep) override {
|
void visit(AstCNew* nodep) override {
|
||||||
if (VN_IS(nodep->dtypep(), VoidDType)) {
|
if (VN_IS(nodep->dtypep(), VoidDType)) {
|
||||||
@ -447,7 +447,7 @@ public:
|
|||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
void visit(AstCMethodHard* nodep) override {
|
void visit(AstCMethodHard* nodep) override {
|
||||||
iterate(nodep->fromp());
|
iterateConst(nodep->fromp());
|
||||||
puts(".");
|
puts(".");
|
||||||
puts(nodep->name());
|
puts(nodep->name());
|
||||||
puts("(");
|
puts("(");
|
||||||
@ -458,7 +458,7 @@ public:
|
|||||||
if (VN_IS(nodep->fromp()->dtypep(), QueueDType) && subnodep->dtypep()->isWide()) {
|
if (VN_IS(nodep->fromp()->dtypep(), QueueDType) && subnodep->dtypep()->isWide()) {
|
||||||
emitCvtWideArray(subnodep, nodep->fromp());
|
emitCvtWideArray(subnodep, nodep->fromp());
|
||||||
} else {
|
} else {
|
||||||
iterate(subnodep);
|
iterateConst(subnodep);
|
||||||
}
|
}
|
||||||
comma = true;
|
comma = true;
|
||||||
}
|
}
|
||||||
@ -477,7 +477,7 @@ public:
|
|||||||
}
|
}
|
||||||
// Probably fragile, V3Task may need to convert to a AstCReturn
|
// Probably fragile, V3Task may need to convert to a AstCReturn
|
||||||
puts(") { return ");
|
puts(") { return ");
|
||||||
iterateAndNextNull(nodep->exprp());
|
iterateAndNextConstNull(nodep->exprp());
|
||||||
puts("; }\n");
|
puts("; }\n");
|
||||||
}
|
}
|
||||||
void visit(AstNodeCase* nodep) override { // LCOV_EXCL_LINE
|
void visit(AstNodeCase* nodep) override { // LCOV_EXCL_LINE
|
||||||
@ -494,7 +494,7 @@ public:
|
|||||||
if (!(nodep->protect() && v3Global.opt.protectIds())) {
|
if (!(nodep->protect() && v3Global.opt.protectIds())) {
|
||||||
putsDecoration(string("// ") + nodep->name() + at + "\n");
|
putsDecoration(string("// ") + nodep->name() + at + "\n");
|
||||||
}
|
}
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstCoverDecl* nodep) override {
|
void visit(AstCoverDecl* nodep) override {
|
||||||
puts("vlSelf->__vlCoverInsert("); // As Declared in emitCoverageDecl
|
puts("vlSelf->__vlCoverInsert("); // As Declared in emitCoverageDecl
|
||||||
@ -537,7 +537,7 @@ public:
|
|||||||
}
|
}
|
||||||
void visit(AstCReturn* nodep) override {
|
void visit(AstCReturn* nodep) override {
|
||||||
puts("return (");
|
puts("return (");
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
puts(");\n");
|
puts(");\n");
|
||||||
}
|
}
|
||||||
void visit(AstDisplay* nodep) override {
|
void visit(AstDisplay* nodep) override {
|
||||||
@ -615,7 +615,7 @@ public:
|
|||||||
emitCvtPackStr(nodep->searchp());
|
emitCvtPackStr(nodep->searchp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
putbs("");
|
putbs("");
|
||||||
iterateAndNextNull(nodep->outp());
|
iterateAndNextConstNull(nodep->outp());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
void visit(AstTestPlusArgs* nodep) override {
|
void visit(AstTestPlusArgs* nodep) override {
|
||||||
@ -626,13 +626,13 @@ public:
|
|||||||
void visit(AstFError* nodep) override {
|
void visit(AstFError* nodep) override {
|
||||||
puts("VL_FERROR_I");
|
puts("VL_FERROR_I");
|
||||||
puts(nodep->strp()->isString() ? "N(" : "W(");
|
puts(nodep->strp()->isString() ? "N(" : "W(");
|
||||||
iterateAndNextNull(nodep->filep());
|
iterateAndNextConstNull(nodep->filep());
|
||||||
putbs(", ");
|
putbs(", ");
|
||||||
if (nodep->strp()->isWide()) {
|
if (nodep->strp()->isWide()) {
|
||||||
puts(cvtToStr(nodep->strp()->widthWords()));
|
puts(cvtToStr(nodep->strp()->widthWords()));
|
||||||
putbs(", ");
|
putbs(", ");
|
||||||
}
|
}
|
||||||
iterateAndNextNull(nodep->strp());
|
iterateAndNextConstNull(nodep->strp());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
void visit(AstFGetS* nodep) override {
|
void visit(AstFGetS* nodep) override {
|
||||||
@ -694,18 +694,18 @@ public:
|
|||||||
{
|
{
|
||||||
const bool need_ptr = !VN_IS(nodep->memp()->dtypep(), AssocArrayDType);
|
const bool need_ptr = !VN_IS(nodep->memp()->dtypep(), AssocArrayDType);
|
||||||
if (need_ptr) puts(" &(");
|
if (need_ptr) puts(" &(");
|
||||||
iterateAndNextNull(nodep->memp());
|
iterateAndNextConstNull(nodep->memp());
|
||||||
if (need_ptr) puts(")");
|
if (need_ptr) puts(")");
|
||||||
}
|
}
|
||||||
putbs(", ");
|
putbs(", ");
|
||||||
if (nodep->lsbp()) {
|
if (nodep->lsbp()) {
|
||||||
iterateAndNextNull(nodep->lsbp());
|
iterateAndNextConstNull(nodep->lsbp());
|
||||||
} else {
|
} else {
|
||||||
puts(cvtToStr(array_lo));
|
puts(cvtToStr(array_lo));
|
||||||
}
|
}
|
||||||
putbs(", ");
|
putbs(", ");
|
||||||
if (nodep->msbp()) {
|
if (nodep->msbp()) {
|
||||||
iterateAndNextNull(nodep->msbp());
|
iterateAndNextConstNull(nodep->msbp());
|
||||||
} else {
|
} else {
|
||||||
puts("~0ULL");
|
puts("~0ULL");
|
||||||
}
|
}
|
||||||
@ -713,7 +713,7 @@ public:
|
|||||||
}
|
}
|
||||||
void visit(AstFClose* nodep) override {
|
void visit(AstFClose* nodep) override {
|
||||||
puts("VL_FCLOSE_I(");
|
puts("VL_FCLOSE_I(");
|
||||||
iterateAndNextNull(nodep->filep());
|
iterateAndNextConstNull(nodep->filep());
|
||||||
puts("); ");
|
puts("); ");
|
||||||
}
|
}
|
||||||
void visit(AstFFlush* nodep) override {
|
void visit(AstFFlush* nodep) override {
|
||||||
@ -721,29 +721,29 @@ public:
|
|||||||
puts("Verilated::runFlushCallbacks();\n");
|
puts("Verilated::runFlushCallbacks();\n");
|
||||||
} else {
|
} else {
|
||||||
puts("if (");
|
puts("if (");
|
||||||
iterateAndNextNull(nodep->filep());
|
iterateAndNextConstNull(nodep->filep());
|
||||||
puts(") { VL_FFLUSH_I(");
|
puts(") { VL_FFLUSH_I(");
|
||||||
iterateAndNextNull(nodep->filep());
|
iterateAndNextConstNull(nodep->filep());
|
||||||
puts("); }\n");
|
puts("); }\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void visit(AstFSeek* nodep) override {
|
void visit(AstFSeek* nodep) override {
|
||||||
puts("(VL_FSEEK_I(");
|
puts("(VL_FSEEK_I(");
|
||||||
iterateAndNextNull(nodep->filep());
|
iterateAndNextConstNull(nodep->filep());
|
||||||
puts(",");
|
puts(",");
|
||||||
iterateAndNextNull(nodep->offset());
|
iterateAndNextConstNull(nodep->offset());
|
||||||
puts(",");
|
puts(",");
|
||||||
iterateAndNextNull(nodep->operation());
|
iterateAndNextConstNull(nodep->operation());
|
||||||
puts(") == -1 ? -1 : 0)");
|
puts(") == -1 ? -1 : 0)");
|
||||||
}
|
}
|
||||||
void visit(AstFTell* nodep) override {
|
void visit(AstFTell* nodep) override {
|
||||||
puts("VL_FTELL_I(");
|
puts("VL_FTELL_I(");
|
||||||
iterateAndNextNull(nodep->filep());
|
iterateAndNextConstNull(nodep->filep());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
void visit(AstFRewind* nodep) override {
|
void visit(AstFRewind* nodep) override {
|
||||||
puts("(VL_FSEEK_I(");
|
puts("(VL_FSEEK_I(");
|
||||||
iterateAndNextNull(nodep->filep());
|
iterateAndNextConstNull(nodep->filep());
|
||||||
puts(", 0, 0) == -1 ? -1 : 0)");
|
puts(", 0, 0) == -1 ? -1 : 0)");
|
||||||
}
|
}
|
||||||
void visit(AstFRead* nodep) override {
|
void visit(AstFRead* nodep) override {
|
||||||
@ -771,19 +771,19 @@ public:
|
|||||||
puts(cvtToStr(array_size));
|
puts(cvtToStr(array_size));
|
||||||
putbs(", ");
|
putbs(", ");
|
||||||
puts("&(");
|
puts("&(");
|
||||||
iterateAndNextNull(nodep->memp());
|
iterateAndNextConstNull(nodep->memp());
|
||||||
puts(")");
|
puts(")");
|
||||||
putbs(", ");
|
putbs(", ");
|
||||||
iterateAndNextNull(nodep->filep());
|
iterateAndNextConstNull(nodep->filep());
|
||||||
putbs(", ");
|
putbs(", ");
|
||||||
if (nodep->startp()) {
|
if (nodep->startp()) {
|
||||||
iterateAndNextNull(nodep->startp());
|
iterateAndNextConstNull(nodep->startp());
|
||||||
} else {
|
} else {
|
||||||
puts(cvtToStr(array_lo));
|
puts(cvtToStr(array_lo));
|
||||||
}
|
}
|
||||||
putbs(", ");
|
putbs(", ");
|
||||||
if (nodep->countp()) {
|
if (nodep->countp()) {
|
||||||
iterateAndNextNull(nodep->countp());
|
iterateAndNextConstNull(nodep->countp());
|
||||||
} else {
|
} else {
|
||||||
puts(cvtToStr(array_size));
|
puts(cvtToStr(array_size));
|
||||||
}
|
}
|
||||||
@ -791,7 +791,7 @@ public:
|
|||||||
}
|
}
|
||||||
void visit(AstSysFuncAsTask* nodep) override {
|
void visit(AstSysFuncAsTask* nodep) override {
|
||||||
if (!nodep->lhsp()->isWide()) puts("(void)");
|
if (!nodep->lhsp()->isWide()) puts("(void)");
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
if (!nodep->lhsp()->isWide()) puts(";");
|
if (!nodep->lhsp()->isWide()) puts(";");
|
||||||
}
|
}
|
||||||
void visit(AstStackTraceF* nodep) override { puts("VL_STACKTRACE_N()"); }
|
void visit(AstStackTraceF* nodep) override { puts("VL_STACKTRACE_N()"); }
|
||||||
@ -805,7 +805,7 @@ public:
|
|||||||
putbs(", ");
|
putbs(", ");
|
||||||
}
|
}
|
||||||
checkMaxWords(nodep->lhsp());
|
checkMaxWords(nodep->lhsp());
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
puts(");\n");
|
puts(");\n");
|
||||||
}
|
}
|
||||||
void visit(AstSystemF* nodep) override {
|
void visit(AstSystemF* nodep) override {
|
||||||
@ -817,18 +817,18 @@ public:
|
|||||||
putbs(", ");
|
putbs(", ");
|
||||||
}
|
}
|
||||||
checkMaxWords(nodep->lhsp());
|
checkMaxWords(nodep->lhsp());
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
void visit(AstStmtExpr* node) override {
|
void visit(AstStmtExpr* node) override {
|
||||||
iterate(node->exprp());
|
iterateConst(node->exprp());
|
||||||
puts(";\n");
|
puts(";\n");
|
||||||
}
|
}
|
||||||
void visit(AstJumpBlock* nodep) override {
|
void visit(AstJumpBlock* nodep) override {
|
||||||
nodep->labelNum(++m_labelNum);
|
nodep->labelNum(++m_labelNum);
|
||||||
puts("{\n"); // Make it visually obvious label jumps outside these
|
puts("{\n"); // Make it visually obvious label jumps outside these
|
||||||
iterateAndNextNull(nodep->stmtsp());
|
iterateAndNextConstNull(nodep->stmtsp());
|
||||||
iterateAndNextNull(nodep->endStmtsp());
|
iterateAndNextConstNull(nodep->endStmtsp());
|
||||||
puts("}\n");
|
puts("}\n");
|
||||||
}
|
}
|
||||||
void visit(AstJumpGo* nodep) override {
|
void visit(AstJumpGo* nodep) override {
|
||||||
@ -838,13 +838,13 @@ public:
|
|||||||
puts("__Vlabel" + cvtToStr(nodep->blockp()->labelNum()) + ": ;\n");
|
puts("__Vlabel" + cvtToStr(nodep->blockp()->labelNum()) + ": ;\n");
|
||||||
}
|
}
|
||||||
void visit(AstWhile* nodep) override {
|
void visit(AstWhile* nodep) override {
|
||||||
iterateAndNextNull(nodep->precondsp());
|
iterateAndNextConstNull(nodep->precondsp());
|
||||||
puts("while (");
|
puts("while (");
|
||||||
iterateAndNextNull(nodep->condp());
|
iterateAndNextConstNull(nodep->condp());
|
||||||
puts(") {\n");
|
puts(") {\n");
|
||||||
iterateAndNextNull(nodep->stmtsp());
|
iterateAndNextConstNull(nodep->stmtsp());
|
||||||
iterateAndNextNull(nodep->incsp());
|
iterateAndNextConstNull(nodep->incsp());
|
||||||
iterateAndNextNull(nodep->precondsp()); // Need to recompute before next loop
|
iterateAndNextConstNull(nodep->precondsp()); // Need to recompute before next loop
|
||||||
puts("}\n");
|
puts("}\n");
|
||||||
}
|
}
|
||||||
void visit(AstNodeIf* nodep) override {
|
void visit(AstNodeIf* nodep) override {
|
||||||
@ -853,20 +853,20 @@ public:
|
|||||||
puts(nodep->branchPred().ascii());
|
puts(nodep->branchPred().ascii());
|
||||||
puts("(");
|
puts("(");
|
||||||
}
|
}
|
||||||
iterateAndNextNull(nodep->condp());
|
iterateAndNextConstNull(nodep->condp());
|
||||||
if (!nodep->branchPred().unknown()) puts(")");
|
if (!nodep->branchPred().unknown()) puts(")");
|
||||||
puts(") {\n");
|
puts(") {\n");
|
||||||
iterateAndNextNull(nodep->thensp());
|
iterateAndNextConstNull(nodep->thensp());
|
||||||
puts("}");
|
puts("}");
|
||||||
if (!nodep->elsesp()) {
|
if (!nodep->elsesp()) {
|
||||||
puts("\n");
|
puts("\n");
|
||||||
} else {
|
} else {
|
||||||
if (VN_IS(nodep->elsesp(), NodeIf) && !nodep->elsesp()->nextp()) {
|
if (VN_IS(nodep->elsesp(), NodeIf) && !nodep->elsesp()->nextp()) {
|
||||||
puts(" else ");
|
puts(" else ");
|
||||||
iterateAndNextNull(nodep->elsesp());
|
iterateAndNextConstNull(nodep->elsesp());
|
||||||
} else {
|
} else {
|
||||||
puts(" else {\n");
|
puts(" else {\n");
|
||||||
iterateAndNextNull(nodep->elsesp());
|
iterateAndNextConstNull(nodep->elsesp());
|
||||||
puts("}\n");
|
puts("}\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -875,9 +875,9 @@ public:
|
|||||||
// GCC allows compound statements in expressions, but this is not standard.
|
// GCC allows compound statements in expressions, but this is not standard.
|
||||||
// So we use an immediate-evaluation lambda and comma operator
|
// So we use an immediate-evaluation lambda and comma operator
|
||||||
putbs("([&]() {\n");
|
putbs("([&]() {\n");
|
||||||
iterateAndNextNull(nodep->stmtsp());
|
iterateAndNextConstNull(nodep->stmtsp());
|
||||||
puts("}(), ");
|
puts("}(), ");
|
||||||
iterateAndNextNull(nodep->resultp());
|
iterateAndNextConstNull(nodep->resultp());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
void visit(AstStop* nodep) override {
|
void visit(AstStop* nodep) override {
|
||||||
@ -921,13 +921,13 @@ public:
|
|||||||
}
|
}
|
||||||
void visit(AstTimeFormat* nodep) override {
|
void visit(AstTimeFormat* nodep) override {
|
||||||
puts("VL_TIMEFORMAT_IINI(");
|
puts("VL_TIMEFORMAT_IINI(");
|
||||||
iterateAndNextNull(nodep->unitsp());
|
iterateAndNextConstNull(nodep->unitsp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
iterateAndNextNull(nodep->precisionp());
|
iterateAndNextConstNull(nodep->precisionp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
emitCvtPackStr(nodep->suffixp());
|
emitCvtPackStr(nodep->suffixp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
iterateAndNextNull(nodep->widthp());
|
iterateAndNextConstNull(nodep->widthp());
|
||||||
puts(", vlSymsp->_vm_contextp__);\n");
|
puts(", vlSymsp->_vm_contextp__);\n");
|
||||||
}
|
}
|
||||||
void visit(AstTimePrecision* nodep) override {
|
void visit(AstTimePrecision* nodep) override {
|
||||||
@ -946,23 +946,23 @@ public:
|
|||||||
void visit(AstTextBlock* nodep) override {
|
void visit(AstTextBlock* nodep) override {
|
||||||
visit(static_cast<AstNodeSimpleText*>(nodep));
|
visit(static_cast<AstNodeSimpleText*>(nodep));
|
||||||
for (AstNode* childp = nodep->nodesp(); childp; childp = childp->nextp()) {
|
for (AstNode* childp = nodep->nodesp(); childp; childp = childp->nextp()) {
|
||||||
iterate(childp);
|
iterateConst(childp);
|
||||||
if (nodep->commas() && childp->nextp()) puts(", ");
|
if (nodep->commas() && childp->nextp()) puts(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void visit(AstCStmt* nodep) override {
|
void visit(AstCStmt* nodep) override {
|
||||||
putbs("");
|
putbs("");
|
||||||
iterateAndNextNull(nodep->exprsp());
|
iterateAndNextConstNull(nodep->exprsp());
|
||||||
}
|
}
|
||||||
void visit(AstCExpr* nodep) override {
|
void visit(AstCExpr* nodep) override {
|
||||||
putbs("");
|
putbs("");
|
||||||
iterateAndNextNull(nodep->exprsp());
|
iterateAndNextConstNull(nodep->exprsp());
|
||||||
}
|
}
|
||||||
void visit(AstUCStmt* nodep) override {
|
void visit(AstUCStmt* nodep) override {
|
||||||
VL_RESTORER(m_inUC);
|
VL_RESTORER(m_inUC);
|
||||||
m_inUC = true;
|
m_inUC = true;
|
||||||
putsDecoration(ifNoProtect("// $c statement at " + nodep->fileline()->ascii() + "\n"));
|
putsDecoration(ifNoProtect("// $c statement at " + nodep->fileline()->ascii() + "\n"));
|
||||||
iterateAndNextNull(nodep->exprsp());
|
iterateAndNextConstNull(nodep->exprsp());
|
||||||
puts("\n");
|
puts("\n");
|
||||||
}
|
}
|
||||||
void visit(AstUCFunc* nodep) override {
|
void visit(AstUCFunc* nodep) override {
|
||||||
@ -970,7 +970,7 @@ public:
|
|||||||
m_inUC = true;
|
m_inUC = true;
|
||||||
puts("\n");
|
puts("\n");
|
||||||
putsDecoration(ifNoProtect("// $c function at " + nodep->fileline()->ascii() + "\n"));
|
putsDecoration(ifNoProtect("// $c function at " + nodep->fileline()->ascii() + "\n"));
|
||||||
iterateAndNextNull(nodep->exprsp());
|
iterateAndNextConstNull(nodep->exprsp());
|
||||||
puts("\n");
|
puts("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -992,7 +992,7 @@ public:
|
|||||||
putbs("(");
|
putbs("(");
|
||||||
puts(nodep->emitSimpleOperator());
|
puts(nodep->emitSimpleOperator());
|
||||||
puts(" ");
|
puts(" ");
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
puts(")");
|
puts(")");
|
||||||
} else {
|
} else {
|
||||||
emitOpName(nodep, nodep->emitC(), nodep->lhsp(), nullptr, nullptr);
|
emitOpName(nodep, nodep->emitC(), nodep->lhsp(), nullptr, nullptr);
|
||||||
@ -1008,11 +1008,11 @@ public:
|
|||||||
}
|
}
|
||||||
if (emitSimpleOk(nodep)) {
|
if (emitSimpleOk(nodep)) {
|
||||||
putbs("(");
|
putbs("(");
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
puts(" ");
|
puts(" ");
|
||||||
putbs(nodep->emitSimpleOperator());
|
putbs(nodep->emitSimpleOperator());
|
||||||
puts(" ");
|
puts(" ");
|
||||||
iterateAndNextNull(nodep->rhsp());
|
iterateAndNextConstNull(nodep->rhsp());
|
||||||
puts(")");
|
puts(")");
|
||||||
} else {
|
} else {
|
||||||
emitOpName(nodep, nodep->emitC(), nodep->lhsp(), nodep->rhsp(), nullptr);
|
emitOpName(nodep, nodep->emitC(), nodep->lhsp(), nodep->rhsp(), nullptr);
|
||||||
@ -1034,7 +1034,7 @@ public:
|
|||||||
putbs("VL_REDXOR_");
|
putbs("VL_REDXOR_");
|
||||||
puts(cvtToStr(widthPow2));
|
puts(cvtToStr(widthPow2));
|
||||||
puts("(");
|
puts("(");
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1045,7 +1045,7 @@ public:
|
|||||||
} else {
|
} else {
|
||||||
puts("(QData)(");
|
puts("(QData)(");
|
||||||
}
|
}
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
void visit(AstNodeCond* nodep) override {
|
void visit(AstNodeCond* nodep) override {
|
||||||
@ -1054,27 +1054,27 @@ public:
|
|||||||
emitOpName(nodep, nodep->emitC(), nodep->condp(), nodep->thenp(), nodep->elsep());
|
emitOpName(nodep, nodep->emitC(), nodep->condp(), nodep->thenp(), nodep->elsep());
|
||||||
} else {
|
} else {
|
||||||
putbs("(");
|
putbs("(");
|
||||||
iterateAndNextNull(nodep->condp());
|
iterateAndNextConstNull(nodep->condp());
|
||||||
putbs(" ? ");
|
putbs(" ? ");
|
||||||
iterateAndNextNull(nodep->thenp());
|
iterateAndNextConstNull(nodep->thenp());
|
||||||
putbs(" : ");
|
putbs(" : ");
|
||||||
iterateAndNextNull(nodep->elsep());
|
iterateAndNextConstNull(nodep->elsep());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void visit(AstMemberSel* nodep) override {
|
void visit(AstMemberSel* nodep) override {
|
||||||
iterateAndNextNull(nodep->fromp());
|
iterateAndNextConstNull(nodep->fromp());
|
||||||
putbs("->");
|
putbs("->");
|
||||||
puts(nodep->varp()->nameProtect());
|
puts(nodep->varp()->nameProtect());
|
||||||
}
|
}
|
||||||
void visit(AstStructSel* nodep) override {
|
void visit(AstStructSel* nodep) override {
|
||||||
iterateAndNextNull(nodep->fromp());
|
iterateAndNextConstNull(nodep->fromp());
|
||||||
putbs(".");
|
putbs(".");
|
||||||
puts(nodep->nameProtect());
|
puts(nodep->nameProtect());
|
||||||
}
|
}
|
||||||
void visit(AstNullCheck* nodep) override {
|
void visit(AstNullCheck* nodep) override {
|
||||||
puts("VL_NULL_CHECK(");
|
puts("VL_NULL_CHECK(");
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
putsQuoted(protect(nodep->fileline()->filename()));
|
putsQuoted(protect(nodep->fileline()->filename()));
|
||||||
puts(", ");
|
puts(", ");
|
||||||
@ -1084,7 +1084,7 @@ public:
|
|||||||
void visit(AstNewCopy* nodep) override {
|
void visit(AstNewCopy* nodep) override {
|
||||||
puts("VL_NEW(" + prefixNameProtect(nodep->dtypep()) + ", ");
|
puts("VL_NEW(" + prefixNameProtect(nodep->dtypep()) + ", ");
|
||||||
puts("*"); // i.e. make into a reference
|
puts("*"); // i.e. make into a reference
|
||||||
iterateAndNextNull(nodep->rhsp());
|
iterateAndNextConstNull(nodep->rhsp());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
void visit(AstSel* nodep) override {
|
void visit(AstSel* nodep) override {
|
||||||
@ -1102,9 +1102,9 @@ public:
|
|||||||
puts("OI(");
|
puts("OI(");
|
||||||
if (nodep->lhsp()) puts(cvtToStr(nodep->lhsp()->widthMin()));
|
if (nodep->lhsp()) puts(cvtToStr(nodep->lhsp()->widthMin()));
|
||||||
puts(",");
|
puts(",");
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
iterateAndNextNull(nodep->rhsp());
|
iterateAndNextConstNull(nodep->rhsp());
|
||||||
puts(")");
|
puts(")");
|
||||||
} else {
|
} else {
|
||||||
emitOpName(nodep, nodep->emitC(), nodep->lhsp(), nodep->rhsp(), nullptr);
|
emitOpName(nodep, nodep->emitC(), nodep->lhsp(), nodep->rhsp(), nullptr);
|
||||||
@ -1122,7 +1122,7 @@ public:
|
|||||||
puts("I(");
|
puts("I(");
|
||||||
puts(cvtToStr(nodep->lhsp()->widthMin()));
|
puts(cvtToStr(nodep->lhsp()->widthMin()));
|
||||||
puts(", ");
|
puts(", ");
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
const uint32_t rd_log2 = V3Number::log2b(VN_AS(nodep->rhsp(), Const)->toUInt());
|
const uint32_t rd_log2 = V3Number::log2b(VN_AS(nodep->rhsp(), Const)->toUInt());
|
||||||
puts(cvtToStr(rd_log2) + ")");
|
puts(cvtToStr(rd_log2) + ")");
|
||||||
@ -1134,9 +1134,9 @@ public:
|
|||||||
}
|
}
|
||||||
void visit(AstCastDynamic* nodep) override {
|
void visit(AstCastDynamic* nodep) override {
|
||||||
putbs("VL_CAST_DYNAMIC(");
|
putbs("VL_CAST_DYNAMIC(");
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
iterateAndNextNull(nodep->rhsp());
|
iterateAndNextConstNull(nodep->rhsp());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
void visit(AstCountBits* nodep) override {
|
void visit(AstCountBits* nodep) override {
|
||||||
@ -1150,16 +1150,16 @@ public:
|
|||||||
// (which is always 32)
|
// (which is always 32)
|
||||||
puts(", ");
|
puts(", ");
|
||||||
}
|
}
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
iterateAndNextNull(nodep->rhsp());
|
iterateAndNextConstNull(nodep->rhsp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
iterateAndNextNull(nodep->thsp());
|
iterateAndNextConstNull(nodep->thsp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
iterateAndNextNull(nodep->fhsp());
|
iterateAndNextConstNull(nodep->fhsp());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
void visit(AstInitItem* nodep) override { iterateChildren(nodep); }
|
void visit(AstInitItem* nodep) override { iterateChildrenConst(nodep); }
|
||||||
// Terminals
|
// Terminals
|
||||||
void visit(AstVarRef* nodep) override {
|
void visit(AstVarRef* nodep) override {
|
||||||
const AstVar* const varp = nodep->varp();
|
const AstVar* const varp = nodep->varp();
|
||||||
@ -1217,17 +1217,17 @@ public:
|
|||||||
puts("()");
|
puts("()");
|
||||||
if (nodep->defaultp()) {
|
if (nodep->defaultp()) {
|
||||||
putbs(".setDefault(");
|
putbs(".setDefault(");
|
||||||
iterateAndNextNull(nodep->defaultp());
|
iterateAndNextConstNull(nodep->defaultp());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void visit(AstSetAssoc* nodep) override {
|
void visit(AstSetAssoc* nodep) override {
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
putbs(".set(");
|
putbs(".set(");
|
||||||
iterateAndNextNull(nodep->keyp());
|
iterateAndNextConstNull(nodep->keyp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
putbs("");
|
putbs("");
|
||||||
iterateAndNextNull(nodep->valuep());
|
iterateAndNextConstNull(nodep->valuep());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
void visit(AstConsWildcard* nodep) override {
|
void visit(AstConsWildcard* nodep) override {
|
||||||
@ -1235,17 +1235,17 @@ public:
|
|||||||
puts("()");
|
puts("()");
|
||||||
if (nodep->defaultp()) {
|
if (nodep->defaultp()) {
|
||||||
putbs(".setDefault(");
|
putbs(".setDefault(");
|
||||||
iterateAndNextNull(nodep->defaultp());
|
iterateAndNextConstNull(nodep->defaultp());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void visit(AstSetWildcard* nodep) override {
|
void visit(AstSetWildcard* nodep) override {
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
putbs(".set(");
|
putbs(".set(");
|
||||||
iterateAndNextNull(nodep->keyp());
|
iterateAndNextConstNull(nodep->keyp());
|
||||||
puts(", ");
|
puts(", ");
|
||||||
putbs("");
|
putbs("");
|
||||||
iterateAndNextNull(nodep->valuep());
|
iterateAndNextConstNull(nodep->valuep());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
void visit(AstConsDynArray* nodep) override {
|
void visit(AstConsDynArray* nodep) override {
|
||||||
@ -1254,12 +1254,12 @@ public:
|
|||||||
puts("()");
|
puts("()");
|
||||||
} else {
|
} else {
|
||||||
puts("::cons(");
|
puts("::cons(");
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
if (nodep->rhsp()) {
|
if (nodep->rhsp()) {
|
||||||
puts(", ");
|
puts(", ");
|
||||||
putbs("");
|
putbs("");
|
||||||
}
|
}
|
||||||
iterateAndNextNull(nodep->rhsp());
|
iterateAndNextConstNull(nodep->rhsp());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1267,7 +1267,7 @@ public:
|
|||||||
putbs(nodep->dtypep()->cType("", false, false));
|
putbs(nodep->dtypep()->cType("", false, false));
|
||||||
puts("{");
|
puts("{");
|
||||||
for (AstNode* memberp = nodep->membersp(); memberp; memberp = memberp->nextp()) {
|
for (AstNode* memberp = nodep->membersp(); memberp; memberp = memberp->nextp()) {
|
||||||
iterate(memberp);
|
iterateConst(memberp);
|
||||||
if (memberp->nextp()) { puts(", "); }
|
if (memberp->nextp()) { puts(", "); }
|
||||||
}
|
}
|
||||||
puts("}");
|
puts("}");
|
||||||
@ -1277,7 +1277,7 @@ public:
|
|||||||
putbs(".");
|
putbs(".");
|
||||||
puts(vdtypep->name());
|
puts(vdtypep->name());
|
||||||
puts(" = ");
|
puts(" = ");
|
||||||
iterate(nodep->rhsp());
|
iterateConst(nodep->rhsp());
|
||||||
}
|
}
|
||||||
void visit(AstConsQueue* nodep) override {
|
void visit(AstConsQueue* nodep) override {
|
||||||
putbs(nodep->dtypep()->cType("", false, false));
|
putbs(nodep->dtypep()->cType("", false, false));
|
||||||
@ -1285,12 +1285,12 @@ public:
|
|||||||
puts("()");
|
puts("()");
|
||||||
} else {
|
} else {
|
||||||
puts("::cons(");
|
puts("::cons(");
|
||||||
iterateAndNextNull(nodep->lhsp());
|
iterateAndNextConstNull(nodep->lhsp());
|
||||||
if (nodep->rhsp()) {
|
if (nodep->rhsp()) {
|
||||||
puts(", ");
|
puts(", ");
|
||||||
putbs("");
|
putbs("");
|
||||||
}
|
}
|
||||||
iterateAndNextNull(nodep->rhsp());
|
iterateAndNextConstNull(nodep->rhsp());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1308,7 +1308,7 @@ public:
|
|||||||
// Default
|
// Default
|
||||||
void visit(AstNode* nodep) override {
|
void visit(AstNode* nodep) override {
|
||||||
puts(string("\n???? // ") + nodep->prettyTypeName() + "\n");
|
puts(string("\n???? // ") + nodep->prettyTypeName() + "\n");
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
// LCOV_EXCL_START
|
// LCOV_EXCL_START
|
||||||
if (!v3Global.opt.lintOnly()) { // An internal problem, so suppress
|
if (!v3Global.opt.lintOnly()) { // An internal problem, so suppress
|
||||||
nodep->v3fatalSrc("Unknown node type reached emitter: " << nodep->prettyTypeName());
|
nodep->v3fatalSrc("Unknown node type reached emitter: " << nodep->prettyTypeName());
|
||||||
@ -1322,7 +1322,7 @@ public:
|
|||||||
: EmitCFunc{} {
|
: EmitCFunc{} {
|
||||||
m_ofp = ofp;
|
m_ofp = ofp;
|
||||||
m_trackText = trackText;
|
m_trackText = trackText;
|
||||||
iterate(nodep);
|
iterateConst(nodep);
|
||||||
}
|
}
|
||||||
~EmitCFunc() override = default;
|
~EmitCFunc() override = default;
|
||||||
};
|
};
|
||||||
|
@ -136,7 +136,7 @@ class EmitCHeader final : public EmitCConstInit {
|
|||||||
puts(varp->dtypep()->cType(varp->nameProtect(), false, false));
|
puts(varp->dtypep()->cType(varp->nameProtect(), false, false));
|
||||||
if (canBeConstexpr) {
|
if (canBeConstexpr) {
|
||||||
puts(" = ");
|
puts(" = ");
|
||||||
iterate(varp->valuep());
|
iterateConst(varp->valuep());
|
||||||
}
|
}
|
||||||
puts(";\n");
|
puts(";\n");
|
||||||
}
|
}
|
||||||
@ -200,7 +200,7 @@ class EmitCHeader final : public EmitCConstInit {
|
|||||||
}
|
}
|
||||||
puts(itemp->nameProtect());
|
puts(itemp->nameProtect());
|
||||||
puts(" = ");
|
puts(" = ");
|
||||||
iterate(itemp->valuep());
|
iterateConst(itemp->valuep());
|
||||||
if (VN_IS(itemp->nextp(), EnumItem)) puts(",");
|
if (VN_IS(itemp->nextp(), EnumItem)) puts(",");
|
||||||
puts("\n");
|
puts("\n");
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ class EmitCImp final : EmitCFunc {
|
|||||||
puts(", ");
|
puts(", ");
|
||||||
puts(varp->nameProtect());
|
puts(varp->nameProtect());
|
||||||
puts("(");
|
puts("(");
|
||||||
iterate(varp->valuep());
|
iterateConst(varp->valuep());
|
||||||
puts(")\n");
|
puts(")\n");
|
||||||
} else if (varp->isIO() && varp->isSc()) {
|
} else if (varp->isIO() && varp->isSc()) {
|
||||||
puts(", ");
|
puts(", ");
|
||||||
@ -522,7 +522,7 @@ class EmitCImp final : EmitCFunc {
|
|||||||
for (AstCFunc* const funcp : pair.second) {
|
for (AstCFunc* const funcp : pair.second) {
|
||||||
VL_RESTORER(m_modp);
|
VL_RESTORER(m_modp);
|
||||||
m_modp = EmitCParentModule::get(funcp);
|
m_modp = EmitCParentModule::get(funcp);
|
||||||
iterate(funcp);
|
iterateConst(funcp);
|
||||||
}
|
}
|
||||||
// Close output file
|
// Close output file
|
||||||
VL_DO_CLEAR(delete m_ofp, m_ofp = nullptr);
|
VL_DO_CLEAR(delete m_ofp, m_ofp = nullptr);
|
||||||
@ -774,7 +774,7 @@ class EmitCTrace final : EmitCFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void emitTraceChangeOne(AstTraceInc* nodep, int arrayindex) {
|
void emitTraceChangeOne(AstTraceInc* nodep, int arrayindex) {
|
||||||
iterateAndNextNull(nodep->precondsp());
|
iterateAndNextConstNull(nodep->precondsp());
|
||||||
const string func = nodep->full() ? "full" : "chg";
|
const string func = nodep->full() ? "full" : "chg";
|
||||||
bool emitWidth = true;
|
bool emitWidth = true;
|
||||||
if (nodep->dtypep()->basicp()->isDouble()) {
|
if (nodep->dtypep()->basicp()->isDouble()) {
|
||||||
@ -817,7 +817,7 @@ class EmitCTrace final : EmitCFunc {
|
|||||||
} else if (emitTraceIsScBv(nodep)) {
|
} else if (emitTraceIsScBv(nodep)) {
|
||||||
puts("VL_SC_BV_DATAP(");
|
puts("VL_SC_BV_DATAP(");
|
||||||
}
|
}
|
||||||
iterate(varrefp); // Put var name out
|
iterateConst(varrefp); // Put var name out
|
||||||
// Tracing only supports 1D arrays
|
// Tracing only supports 1D arrays
|
||||||
if (nodep->declp()->arrayRange().ranged()) {
|
if (nodep->declp()->arrayRange().ranged()) {
|
||||||
if (arrayindex == -2) {
|
if (arrayindex == -2) {
|
||||||
@ -839,7 +839,7 @@ class EmitCTrace final : EmitCFunc {
|
|||||||
puts(")");
|
puts(")");
|
||||||
} else {
|
} else {
|
||||||
puts("(");
|
puts("(");
|
||||||
iterate(nodep->valuep());
|
iterateConst(nodep->valuep());
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -901,7 +901,7 @@ class EmitCTrace final : EmitCFunc {
|
|||||||
openNextOutputFile();
|
openNextOutputFile();
|
||||||
// Emit functions
|
// Emit functions
|
||||||
for (AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) {
|
for (AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) {
|
||||||
if (AstCFunc* const funcp = VN_CAST(nodep, CFunc)) { iterate(funcp); }
|
if (AstCFunc* const funcp = VN_CAST(nodep, CFunc)) { iterateConst(funcp); }
|
||||||
}
|
}
|
||||||
// Close output file
|
// Close output file
|
||||||
VL_DO_CLEAR(delete m_ofp, m_ofp = nullptr);
|
VL_DO_CLEAR(delete m_ofp, m_ofp = nullptr);
|
||||||
|
@ -28,7 +28,7 @@ VL_DEFINE_DEBUG_FUNCTIONS;
|
|||||||
|
|
||||||
//######################################################################
|
//######################################################################
|
||||||
|
|
||||||
class EmitCInlines final : EmitCBaseVisitor {
|
class EmitCInlines final : EmitCBaseVisitorConst {
|
||||||
// STATE
|
// STATE
|
||||||
|
|
||||||
// METHODS
|
// METHODS
|
||||||
@ -37,26 +37,26 @@ class EmitCInlines final : EmitCBaseVisitor {
|
|||||||
void visit(AstCNew* nodep) override {
|
void visit(AstCNew* nodep) override {
|
||||||
if (v3Global.opt.savable())
|
if (v3Global.opt.savable())
|
||||||
v3warn(E_UNSUPPORTED, "Unsupported: --savable with dynamic new");
|
v3warn(E_UNSUPPORTED, "Unsupported: --savable with dynamic new");
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstDumpCtl* nodep) override {
|
void visit(AstDumpCtl* nodep) override {
|
||||||
if (v3Global.opt.trace()) v3Global.needTraceDumper(true);
|
if (v3Global.opt.trace()) v3Global.needTraceDumper(true);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstNodeDistBiop* nodep) override {
|
void visit(AstNodeDistBiop* nodep) override {
|
||||||
v3Global.setUsesProbDist();
|
v3Global.setUsesProbDist();
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstNodeDistTriop* nodep) override {
|
void visit(AstNodeDistTriop* nodep) override {
|
||||||
v3Global.setUsesProbDist();
|
v3Global.setUsesProbDist();
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------
|
//---------------------------------------
|
||||||
void visit(AstNode* nodep) override { iterateChildren(nodep); }
|
void visit(AstNode* nodep) override { iterateChildrenConst(nodep); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EmitCInlines(AstNetlist* nodep) { iterate(nodep); }
|
explicit EmitCInlines(AstNetlist* nodep) { iterateConst(nodep); }
|
||||||
};
|
};
|
||||||
|
|
||||||
//######################################################################
|
//######################################################################
|
||||||
@ -64,5 +64,5 @@ public:
|
|||||||
|
|
||||||
void V3EmitC::emitcInlines() {
|
void V3EmitC::emitcInlines() {
|
||||||
UINFO(2, __FUNCTION__ << ": " << endl);
|
UINFO(2, __FUNCTION__ << ": " << endl);
|
||||||
EmitCInlines(v3Global.rootp());
|
{ EmitCInlines visitor{v3Global.rootp()}; }
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,12 @@ VL_DEFINE_DEBUG_FUNCTIONS;
|
|||||||
|
|
||||||
//######################################################################
|
//######################################################################
|
||||||
|
|
||||||
class EmitCMain final : EmitCBaseVisitor {
|
class EmitCMain final : EmitCBaseVisitorConst {
|
||||||
// METHODS
|
// METHODS
|
||||||
|
|
||||||
// VISITORS
|
// VISITORS
|
||||||
// This visitor doesn't really iterate, but exist to appease base class
|
// This visitor doesn't really iterate, but exist to appease base class
|
||||||
void visit(AstNode* nodep) override { iterateChildren(nodep); } // LCOV_EXCL_LINE
|
void visit(AstNode* nodep) override { iterateChildrenConst(nodep); } // LCOV_EXCL_LINE
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
|
@ -658,7 +658,7 @@ class EmitCModel final : public EmitCFunc {
|
|||||||
puts("\n");
|
puts("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
iterate(funcp);
|
iterateConst(funcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_ofp) { VL_DO_CLEAR(delete m_ofp, m_ofp = nullptr); }
|
if (m_ofp) { VL_DO_CLEAR(delete m_ofp, m_ofp = nullptr); }
|
||||||
|
@ -32,7 +32,7 @@ VL_DEFINE_DEBUG_FUNCTIONS;
|
|||||||
//######################################################################
|
//######################################################################
|
||||||
// Symbol table emitting
|
// Symbol table emitting
|
||||||
|
|
||||||
class EmitCSyms final : EmitCBaseVisitor {
|
class EmitCSyms final : EmitCBaseVisitorConst {
|
||||||
// NODE STATE
|
// NODE STATE
|
||||||
// Cleared on Netlist
|
// Cleared on Netlist
|
||||||
// AstNodeModule::user1() -> bool. Set true __Vconfigure called
|
// AstNodeModule::user1() -> bool. Set true __Vconfigure called
|
||||||
@ -278,7 +278,7 @@ class EmitCSyms final : EmitCBaseVisitor {
|
|||||||
// VISITORS
|
// VISITORS
|
||||||
void visit(AstNetlist* nodep) override {
|
void visit(AstNetlist* nodep) override {
|
||||||
// Collect list of scopes
|
// Collect list of scopes
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
varsExpand();
|
varsExpand();
|
||||||
|
|
||||||
if (v3Global.opt.vpi()) buildVpiHierarchy();
|
if (v3Global.opt.vpi()) buildVpiHierarchy();
|
||||||
@ -304,7 +304,7 @@ class EmitCSyms final : EmitCBaseVisitor {
|
|||||||
VL_RESTORER(m_modp);
|
VL_RESTORER(m_modp);
|
||||||
{
|
{
|
||||||
m_modp = nodep;
|
m_modp = nodep;
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void visit(AstCellInline* nodep) override {
|
void visit(AstCellInline* nodep) override {
|
||||||
@ -356,7 +356,7 @@ class EmitCSyms final : EmitCBaseVisitor {
|
|||||||
}
|
}
|
||||||
void visit(AstVar* nodep) override {
|
void visit(AstVar* nodep) override {
|
||||||
nameCheck(nodep);
|
nameCheck(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
if (nodep->isSigUserRdPublic() && !m_cfuncp)
|
if (nodep->isSigUserRdPublic() && !m_cfuncp)
|
||||||
m_modVars.emplace_back(std::make_pair(m_modp, nodep));
|
m_modVars.emplace_back(std::make_pair(m_modp, nodep));
|
||||||
}
|
}
|
||||||
@ -372,18 +372,18 @@ class EmitCSyms final : EmitCBaseVisitor {
|
|||||||
VL_RESTORER(m_cfuncp);
|
VL_RESTORER(m_cfuncp);
|
||||||
{
|
{
|
||||||
m_cfuncp = nodep;
|
m_cfuncp = nodep;
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------
|
//---------------------------------------
|
||||||
void visit(AstConst*) override {}
|
void visit(AstConst*) override {}
|
||||||
void visit(AstNode* nodep) override { iterateChildren(nodep); }
|
void visit(AstNode* nodep) override { iterateChildrenConst(nodep); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EmitCSyms(AstNetlist* nodep, bool dpiHdrOnly)
|
explicit EmitCSyms(AstNetlist* nodep, bool dpiHdrOnly)
|
||||||
: m_dpiHdrOnly{dpiHdrOnly} {
|
: m_dpiHdrOnly{dpiHdrOnly} {
|
||||||
iterate(nodep);
|
iterateConst(nodep);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ VL_DEFINE_DEBUG_FUNCTIONS;
|
|||||||
// ######################################################################
|
// ######################################################################
|
||||||
// Emit statements and expressions
|
// Emit statements and expressions
|
||||||
|
|
||||||
class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
class EmitVBaseVisitorConst VL_NOT_FINAL : public EmitCBaseVisitorConst {
|
||||||
// MEMBERS
|
// MEMBERS
|
||||||
bool m_suppressSemi = false;
|
bool m_suppressSemi = false;
|
||||||
const bool m_suppressUnknown = false;
|
const bool m_suppressUnknown = false;
|
||||||
@ -166,7 +166,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||||||
// AstSenItem is called for dumping in isolation by V3Order
|
// AstSenItem is called for dumping in isolation by V3Order
|
||||||
putfs(nodep, "@(");
|
putfs(nodep, "@(");
|
||||||
for (AstNode* expp = nodep->sensesp(); expp; expp = expp->nextp()) {
|
for (AstNode* expp = nodep->sensesp(); expp; expp = expp->nextp()) {
|
||||||
iterate(expp);
|
iterateConst(expp);
|
||||||
if (expp->nextp()) putqs(expp->nextp(), " or ");
|
if (expp->nextp()) putqs(expp->nextp(), " or ");
|
||||||
}
|
}
|
||||||
puts(")");
|
puts(")");
|
||||||
@ -382,7 +382,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||||||
void visit(AstStop* nodep) override { putfs(nodep, "$stop;\n"); }
|
void visit(AstStop* nodep) override { putfs(nodep, "$stop;\n"); }
|
||||||
void visit(AstFinish* nodep) override { putfs(nodep, "$finish;\n"); }
|
void visit(AstFinish* nodep) override { putfs(nodep, "$finish;\n"); }
|
||||||
void visit(AstStmtExpr* nodep) override {
|
void visit(AstStmtExpr* nodep) override {
|
||||||
iterate(nodep->exprp());
|
iterateConst(nodep->exprp());
|
||||||
puts(";\n");
|
puts(";\n");
|
||||||
}
|
}
|
||||||
void visit(AstNodeSimpleText* nodep) override {
|
void visit(AstNodeSimpleText* nodep) override {
|
||||||
@ -398,7 +398,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||||||
VL_RESTORER(m_suppressSemi);
|
VL_RESTORER(m_suppressSemi);
|
||||||
m_suppressVarSemi = nodep->commas();
|
m_suppressVarSemi = nodep->commas();
|
||||||
for (AstNode* childp = nodep->nodesp(); childp; childp = childp->nextp()) {
|
for (AstNode* childp = nodep->nodesp(); childp; childp = childp->nextp()) {
|
||||||
iterate(childp);
|
iterateConst(childp);
|
||||||
if (nodep->commas() && childp->nextp()) puts(", ");
|
if (nodep->commas() && childp->nextp()) puts(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -426,11 +426,11 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void visit(AstCMethodHard* nodep) override {
|
void visit(AstCMethodHard* nodep) override {
|
||||||
iterate(nodep->fromp());
|
iterateConst(nodep->fromp());
|
||||||
puts("." + nodep->name() + "(");
|
puts("." + nodep->name() + "(");
|
||||||
for (AstNode* pinp = nodep->pinsp(); pinp; pinp = pinp->nextp()) {
|
for (AstNode* pinp = nodep->pinsp(); pinp; pinp = pinp->nextp()) {
|
||||||
if (pinp != nodep->pinsp()) puts(", ");
|
if (pinp != nodep->pinsp()) puts(", ");
|
||||||
iterate(pinp);
|
iterateConst(pinp);
|
||||||
}
|
}
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
@ -506,12 +506,12 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||||||
nodep->thsp());
|
nodep->thsp());
|
||||||
}
|
}
|
||||||
void visit(AstMemberSel* nodep) override {
|
void visit(AstMemberSel* nodep) override {
|
||||||
iterate(nodep->fromp());
|
iterateConst(nodep->fromp());
|
||||||
puts(".");
|
puts(".");
|
||||||
puts(nodep->prettyName());
|
puts(nodep->prettyName());
|
||||||
}
|
}
|
||||||
void visit(AstStructSel* nodep) override {
|
void visit(AstStructSel* nodep) override {
|
||||||
iterate(nodep->fromp());
|
iterateConst(nodep->fromp());
|
||||||
puts(".");
|
puts(".");
|
||||||
puts(nodep->prettyName());
|
puts(nodep->prettyName());
|
||||||
}
|
}
|
||||||
@ -533,7 +533,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||||||
puts(cvtToStr(itr.first));
|
puts(cvtToStr(itr.first));
|
||||||
puts(":");
|
puts(":");
|
||||||
AstNode* const valuep = itr.second->valuep();
|
AstNode* const valuep = itr.second->valuep();
|
||||||
iterate(valuep);
|
iterateConst(valuep);
|
||||||
}
|
}
|
||||||
puts("}");
|
puts("}");
|
||||||
}
|
}
|
||||||
@ -613,13 +613,13 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||||||
}
|
}
|
||||||
void visit(AstConstDType* nodep) override {
|
void visit(AstConstDType* nodep) override {
|
||||||
putfs(nodep, "const ");
|
putfs(nodep, "const ");
|
||||||
iterate(nodep->subDTypep());
|
iterateConst(nodep->subDTypep());
|
||||||
}
|
}
|
||||||
void visit(AstNodeArrayDType* nodep) override {
|
void visit(AstNodeArrayDType* nodep) override {
|
||||||
iterate(nodep->subDTypep());
|
iterateConst(nodep->subDTypep());
|
||||||
iterateAndNextConstNull(nodep->rangep());
|
iterateAndNextConstNull(nodep->rangep());
|
||||||
}
|
}
|
||||||
void visit(AstRefDType* nodep) override { iterate(nodep->skipRefp()); }
|
void visit(AstRefDType* nodep) override { iterateConst(nodep->skipRefp()); }
|
||||||
void visit(AstNodeUOrStructDType* nodep) override {
|
void visit(AstNodeUOrStructDType* nodep) override {
|
||||||
puts(nodep->verilogKwd() + " ");
|
puts(nodep->verilogKwd() + " ");
|
||||||
if (nodep->packed()) puts("packed ");
|
if (nodep->packed()) puts("packed ");
|
||||||
@ -627,13 +627,13 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||||||
puts("{");
|
puts("{");
|
||||||
for (AstMemberDType* itemp = nodep->membersp(); itemp;
|
for (AstMemberDType* itemp = nodep->membersp(); itemp;
|
||||||
itemp = VN_AS(itemp->nextp(), MemberDType)) {
|
itemp = VN_AS(itemp->nextp(), MemberDType)) {
|
||||||
iterate(itemp);
|
iterateConst(itemp);
|
||||||
puts(";");
|
puts(";");
|
||||||
}
|
}
|
||||||
puts("}");
|
puts("}");
|
||||||
}
|
}
|
||||||
void visit(AstMemberDType* nodep) override {
|
void visit(AstMemberDType* nodep) override {
|
||||||
iterate(nodep->subDTypep());
|
iterateConst(nodep->subDTypep());
|
||||||
puts(" ");
|
puts(" ");
|
||||||
puts(nodep->name());
|
puts(nodep->name());
|
||||||
}
|
}
|
||||||
@ -698,7 +698,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||||||
unpackps.push_back(unpackp);
|
unpackps.push_back(unpackp);
|
||||||
dtypep = unpackp->subDTypep();
|
dtypep = unpackp->subDTypep();
|
||||||
} else {
|
} else {
|
||||||
iterate(dtypep);
|
iterateConst(dtypep);
|
||||||
puts(" ");
|
puts(" ");
|
||||||
puts(nodep->prettyName());
|
puts(nodep->prettyName());
|
||||||
dtypep = nullptr;
|
dtypep = nullptr;
|
||||||
@ -740,16 +740,16 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
bool m_suppressVarSemi = false; // Suppress emitting semicolon for AstVars
|
bool m_suppressVarSemi = false; // Suppress emitting semicolon for AstVars
|
||||||
explicit EmitVBaseVisitor(bool suppressUnknown, AstSenTree* domainp)
|
explicit EmitVBaseVisitorConst(bool suppressUnknown, AstSenTree* domainp)
|
||||||
: m_suppressUnknown{suppressUnknown}
|
: m_suppressUnknown{suppressUnknown}
|
||||||
, m_sensesp{domainp} {}
|
, m_sensesp{domainp} {}
|
||||||
~EmitVBaseVisitor() override = default;
|
~EmitVBaseVisitorConst() override = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
//######################################################################
|
//######################################################################
|
||||||
// Emit to an output file
|
// Emit to an output file
|
||||||
|
|
||||||
class EmitVFileVisitor final : public EmitVBaseVisitor {
|
class EmitVFileVisitor final : public EmitVBaseVisitorConst {
|
||||||
// METHODS
|
// METHODS
|
||||||
void puts(const string& str) override { ofp()->puts(str); }
|
void puts(const string& str) override { ofp()->puts(str); }
|
||||||
void putbs(const string& str) override { ofp()->putbs(str); }
|
void putbs(const string& str) override { ofp()->putbs(str); }
|
||||||
@ -759,10 +759,10 @@ class EmitVFileVisitor final : public EmitVBaseVisitor {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
EmitVFileVisitor(AstNode* nodep, V3OutVFile* ofp, bool trackText, bool suppressUnknown)
|
EmitVFileVisitor(AstNode* nodep, V3OutVFile* ofp, bool trackText, bool suppressUnknown)
|
||||||
: EmitVBaseVisitor{suppressUnknown, nullptr} {
|
: EmitVBaseVisitorConst{suppressUnknown, nullptr} {
|
||||||
m_ofp = ofp;
|
m_ofp = ofp;
|
||||||
m_trackText = trackText;
|
m_trackText = trackText;
|
||||||
iterate(nodep);
|
iterateConst(nodep);
|
||||||
}
|
}
|
||||||
~EmitVFileVisitor() override = default;
|
~EmitVFileVisitor() override = default;
|
||||||
};
|
};
|
||||||
@ -770,7 +770,7 @@ public:
|
|||||||
//######################################################################
|
//######################################################################
|
||||||
// Emit to a stream (perhaps stringstream)
|
// Emit to a stream (perhaps stringstream)
|
||||||
|
|
||||||
class EmitVStreamVisitor final : public EmitVBaseVisitor {
|
class EmitVStreamVisitor final : public EmitVBaseVisitorConst {
|
||||||
// MEMBERS
|
// MEMBERS
|
||||||
std::ostream& m_os;
|
std::ostream& m_os;
|
||||||
// METHODS
|
// METHODS
|
||||||
@ -782,9 +782,9 @@ class EmitVStreamVisitor final : public EmitVBaseVisitor {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
EmitVStreamVisitor(const AstNode* nodep, std::ostream& os)
|
EmitVStreamVisitor(const AstNode* nodep, std::ostream& os)
|
||||||
: EmitVBaseVisitor{false, nullptr}
|
: EmitVBaseVisitorConst{false, nullptr}
|
||||||
, m_os(os) { // Need () or GCC 4.8 false warning
|
, m_os(os) { // Need () or GCC 4.8 false warning
|
||||||
iterate(const_cast<AstNode*>(nodep));
|
iterateConst(const_cast<AstNode*>(nodep));
|
||||||
}
|
}
|
||||||
~EmitVStreamVisitor() override = default;
|
~EmitVStreamVisitor() override = default;
|
||||||
};
|
};
|
||||||
@ -837,7 +837,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class EmitVPrefixedVisitor final : public EmitVBaseVisitor {
|
class EmitVPrefixedVisitor final : public EmitVBaseVisitorConst {
|
||||||
// MEMBERS
|
// MEMBERS
|
||||||
EmitVPrefixedFormatter m_formatter; // Special verilog formatter (Way down the
|
EmitVPrefixedFormatter m_formatter; // Special verilog formatter (Way down the
|
||||||
// inheritance is another unused V3OutFormatter)
|
// inheritance is another unused V3OutFormatter)
|
||||||
@ -861,10 +861,10 @@ class EmitVPrefixedVisitor final : public EmitVBaseVisitor {
|
|||||||
public:
|
public:
|
||||||
EmitVPrefixedVisitor(const AstNode* nodep, std::ostream& os, const string& prefix, int flWidth,
|
EmitVPrefixedVisitor(const AstNode* nodep, std::ostream& os, const string& prefix, int flWidth,
|
||||||
AstSenTree* domainp, bool user3mark)
|
AstSenTree* domainp, bool user3mark)
|
||||||
: EmitVBaseVisitor{false, domainp}
|
: EmitVBaseVisitorConst{false, domainp}
|
||||||
, m_formatter{os, prefix, flWidth} {
|
, m_formatter{os, prefix, flWidth} {
|
||||||
if (user3mark) VNUser3InUse::check();
|
if (user3mark) VNUser3InUse::check();
|
||||||
iterate(const_cast<AstNode*>(nodep));
|
iterateConst(const_cast<AstNode*>(nodep));
|
||||||
}
|
}
|
||||||
~EmitVPrefixedVisitor() override = default;
|
~EmitVPrefixedVisitor() override = default;
|
||||||
};
|
};
|
||||||
|
@ -31,7 +31,7 @@ VL_DEFINE_DEBUG_FUNCTIONS;
|
|||||||
// ######################################################################
|
// ######################################################################
|
||||||
// Emit statements and expressions
|
// Emit statements and expressions
|
||||||
|
|
||||||
class EmitXmlFileVisitor final : public VNVisitor {
|
class EmitXmlFileVisitor final : public VNVisitorConst {
|
||||||
// NODE STATE
|
// NODE STATE
|
||||||
// Entire netlist:
|
// Entire netlist:
|
||||||
// AstNode::user1 -> uint64_t, number to connect crossrefs
|
// AstNode::user1 -> uint64_t, number to connect crossrefs
|
||||||
@ -94,7 +94,7 @@ class EmitXmlFileVisitor final : public VNVisitor {
|
|||||||
if (tag == "") tag = VString::downcase(nodep->typeName());
|
if (tag == "") tag = VString::downcase(nodep->typeName());
|
||||||
if (nodep->op1p() || nodep->op2p() || nodep->op3p() || nodep->op4p()) {
|
if (nodep->op1p() || nodep->op2p() || nodep->op3p() || nodep->op4p()) {
|
||||||
puts(">\n");
|
puts(">\n");
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
puts("</" + tag + ">\n");
|
puts("</" + tag + ">\n");
|
||||||
} else {
|
} else {
|
||||||
puts("/>\n");
|
puts("/>\n");
|
||||||
@ -117,13 +117,13 @@ class EmitXmlFileVisitor final : public VNVisitor {
|
|||||||
void visit(AstNodeIf* nodep) override {
|
void visit(AstNodeIf* nodep) override {
|
||||||
outputTag(nodep, "if");
|
outputTag(nodep, "if");
|
||||||
puts(">\n");
|
puts(">\n");
|
||||||
iterateAndNextNull(nodep->condp());
|
iterateAndNextConstNull(nodep->condp());
|
||||||
puts("<begin>\n");
|
puts("<begin>\n");
|
||||||
iterateAndNextNull(nodep->thensp());
|
iterateAndNextConstNull(nodep->thensp());
|
||||||
puts("</begin>\n");
|
puts("</begin>\n");
|
||||||
if (nodep->elsesp()) {
|
if (nodep->elsesp()) {
|
||||||
puts("<begin>\n");
|
puts("<begin>\n");
|
||||||
iterateAndNextNull(nodep->elsesp());
|
iterateAndNextConstNull(nodep->elsesp());
|
||||||
puts("</begin>\n");
|
puts("</begin>\n");
|
||||||
}
|
}
|
||||||
puts("</if>\n");
|
puts("</if>\n");
|
||||||
@ -132,34 +132,34 @@ class EmitXmlFileVisitor final : public VNVisitor {
|
|||||||
outputTag(nodep, "while");
|
outputTag(nodep, "while");
|
||||||
puts(">\n");
|
puts(">\n");
|
||||||
puts("<begin>\n");
|
puts("<begin>\n");
|
||||||
iterateAndNextNull(nodep->precondsp());
|
iterateAndNextConstNull(nodep->precondsp());
|
||||||
puts("</begin>\n");
|
puts("</begin>\n");
|
||||||
if (nodep->condp()) {
|
if (nodep->condp()) {
|
||||||
puts("<begin>\n");
|
puts("<begin>\n");
|
||||||
iterateAndNextNull(nodep->condp());
|
iterateAndNextConstNull(nodep->condp());
|
||||||
puts("</begin>\n");
|
puts("</begin>\n");
|
||||||
}
|
}
|
||||||
if (nodep->stmtsp()) {
|
if (nodep->stmtsp()) {
|
||||||
puts("<begin>\n");
|
puts("<begin>\n");
|
||||||
iterateAndNextNull(nodep->stmtsp());
|
iterateAndNextConstNull(nodep->stmtsp());
|
||||||
puts("</begin>\n");
|
puts("</begin>\n");
|
||||||
}
|
}
|
||||||
if (nodep->incsp()) {
|
if (nodep->incsp()) {
|
||||||
puts("<begin>\n");
|
puts("<begin>\n");
|
||||||
iterateAndNextNull(nodep->incsp());
|
iterateAndNextConstNull(nodep->incsp());
|
||||||
puts("</begin>\n");
|
puts("</begin>\n");
|
||||||
}
|
}
|
||||||
puts("</while>\n");
|
puts("</while>\n");
|
||||||
}
|
}
|
||||||
void visit(AstNetlist* nodep) override {
|
void visit(AstNetlist* nodep) override {
|
||||||
puts("<netlist>\n");
|
puts("<netlist>\n");
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
puts("</netlist>\n");
|
puts("</netlist>\n");
|
||||||
}
|
}
|
||||||
void visit(AstConstPool* nodep) override {
|
void visit(AstConstPool* nodep) override {
|
||||||
if (!v3Global.opt.xmlOnly()) {
|
if (!v3Global.opt.xmlOnly()) {
|
||||||
puts("<constpool>\n");
|
puts("<constpool>\n");
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
puts("</constpool>\n");
|
puts("</constpool>\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ class EmitXmlFileVisitor final : public VNVisitor {
|
|||||||
puts("<inititem index=\"");
|
puts("<inititem index=\"");
|
||||||
puts(cvtToStr(itr.first));
|
puts(cvtToStr(itr.first));
|
||||||
puts("\">\n");
|
puts("\">\n");
|
||||||
iterateChildren(itr.second);
|
iterateChildrenConst(itr.second);
|
||||||
puts("</inititem>\n");
|
puts("</inititem>\n");
|
||||||
}
|
}
|
||||||
puts("</initarray>\n");
|
puts("</initarray>\n");
|
||||||
@ -314,7 +314,7 @@ class EmitXmlFileVisitor final : public VNVisitor {
|
|||||||
public:
|
public:
|
||||||
EmitXmlFileVisitor(AstNode* nodep, V3OutFile* ofp)
|
EmitXmlFileVisitor(AstNode* nodep, V3OutFile* ofp)
|
||||||
: m_ofp{ofp} {
|
: m_ofp{ofp} {
|
||||||
iterate(nodep);
|
iterateConst(nodep);
|
||||||
}
|
}
|
||||||
~EmitXmlFileVisitor() override = default;
|
~EmitXmlFileVisitor() override = default;
|
||||||
};
|
};
|
||||||
@ -322,7 +322,7 @@ public:
|
|||||||
//######################################################################
|
//######################################################################
|
||||||
// List of module files xml visitor
|
// List of module files xml visitor
|
||||||
|
|
||||||
class ModuleFilesXmlVisitor final : public VNVisitor {
|
class ModuleFilesXmlVisitor final : public VNVisitorConst {
|
||||||
private:
|
private:
|
||||||
// MEMBERS
|
// MEMBERS
|
||||||
std::ostream& m_os;
|
std::ostream& m_os;
|
||||||
@ -354,7 +354,7 @@ public:
|
|||||||
ModuleFilesXmlVisitor(AstNetlist* nodep, std::ostream& os)
|
ModuleFilesXmlVisitor(AstNetlist* nodep, std::ostream& os)
|
||||||
: m_os(os) { // Need () or GCC 4.8 false warning
|
: m_os(os) { // Need () or GCC 4.8 false warning
|
||||||
// Operate on whole netlist
|
// Operate on whole netlist
|
||||||
nodep->accept(*this);
|
iterateConst(nodep);
|
||||||
// Xml output
|
// Xml output
|
||||||
m_os << "<module_files>\n";
|
m_os << "<module_files>\n";
|
||||||
for (const FileLine* ifp : m_nodeModules) {
|
for (const FileLine* ifp : m_nodeModules) {
|
||||||
@ -369,7 +369,7 @@ public:
|
|||||||
//######################################################################
|
//######################################################################
|
||||||
// Hierarchy of Cells visitor
|
// Hierarchy of Cells visitor
|
||||||
|
|
||||||
class HierCellsXmlVisitor final : public VNVisitor {
|
class HierCellsXmlVisitor final : public VNVisitorConst {
|
||||||
private:
|
private:
|
||||||
// MEMBERS
|
// MEMBERS
|
||||||
std::ostream& m_os;
|
std::ostream& m_os;
|
||||||
@ -391,7 +391,7 @@ private:
|
|||||||
<< " hier=\"" << nodep->prettyName() << "\"";
|
<< " hier=\"" << nodep->prettyName() << "\"";
|
||||||
m_hier = nodep->prettyName() + ".";
|
m_hier = nodep->prettyName() + ".";
|
||||||
m_hasChildren = false;
|
m_hasChildren = false;
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
if (m_hasChildren) {
|
if (m_hasChildren) {
|
||||||
m_os << "</cell>\n";
|
m_os << "</cell>\n";
|
||||||
} else {
|
} else {
|
||||||
@ -410,7 +410,7 @@ private:
|
|||||||
const std::string hier = m_hier;
|
const std::string hier = m_hier;
|
||||||
m_hier += nodep->name() + ".";
|
m_hier += nodep->name() + ".";
|
||||||
m_hasChildren = false;
|
m_hasChildren = false;
|
||||||
iterateChildren(nodep->modp());
|
iterateChildrenConst(nodep->modp());
|
||||||
if (m_hasChildren) {
|
if (m_hasChildren) {
|
||||||
m_os << "</cell>\n";
|
m_os << "</cell>\n";
|
||||||
} else {
|
} else {
|
||||||
@ -420,14 +420,13 @@ private:
|
|||||||
m_hasChildren = true;
|
m_hasChildren = true;
|
||||||
}
|
}
|
||||||
//-----
|
//-----
|
||||||
void visit(AstNode* nodep) override { iterateChildren(nodep); }
|
void visit(AstNode* nodep) override { iterateChildrenConst(nodep); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
HierCellsXmlVisitor(AstNetlist* nodep, std::ostream& os)
|
HierCellsXmlVisitor(AstNetlist* nodep, std::ostream& os)
|
||||||
: m_os(os) { // Need () or GCC 4.8 false warning
|
: m_os(os) { // Need () or GCC 4.8 false warning
|
||||||
// Operate on whole netlist
|
iterateConst(nodep);
|
||||||
nodep->accept(*this);
|
|
||||||
}
|
}
|
||||||
~HierCellsXmlVisitor() override = default;
|
~HierCellsXmlVisitor() override = default;
|
||||||
};
|
};
|
||||||
|
@ -192,7 +192,7 @@ public:
|
|||||||
// ######################################################################
|
// ######################################################################
|
||||||
// Is this a simple expression with a single input and single output?
|
// Is this a simple expression with a single input and single output?
|
||||||
|
|
||||||
class GateOkVisitor final : public VNVisitor {
|
class GateOkVisitor final : public VNVisitorConst {
|
||||||
private:
|
private:
|
||||||
// RETURN STATE
|
// RETURN STATE
|
||||||
bool m_isSimple = true; // Set false when we know it isn't simple
|
bool m_isSimple = true; // Set false when we know it isn't simple
|
||||||
@ -215,7 +215,7 @@ private:
|
|||||||
// VISITORS
|
// VISITORS
|
||||||
void visit(AstNodeVarRef* nodep) override {
|
void visit(AstNodeVarRef* nodep) override {
|
||||||
++m_ops;
|
++m_ops;
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
// We only allow a LHS ref for the var being set, and a RHS ref for
|
// We only allow a LHS ref for the var being set, and a RHS ref for
|
||||||
// something else being read.
|
// something else being read.
|
||||||
if (nodep->varScopep()->varp()->isSc()) {
|
if (nodep->varScopep()->varp()->isSc()) {
|
||||||
@ -246,7 +246,7 @@ private:
|
|||||||
} else if (nodep->isTimingControl()) {
|
} else if (nodep->isTimingControl()) {
|
||||||
clearSimple("Timing control");
|
clearSimple("Timing control");
|
||||||
} else {
|
} else {
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
// We don't push logic other then assignments/NOTs into SenItems
|
// We don't push logic other then assignments/NOTs into SenItems
|
||||||
// This avoids a mess in computing what exactly a POSEDGE is
|
// This avoids a mess in computing what exactly a POSEDGE is
|
||||||
@ -271,7 +271,7 @@ private:
|
|||||||
UINFO(5, "Non optimizable type: " << nodep << endl);
|
UINFO(5, "Non optimizable type: " << nodep << endl);
|
||||||
clearSimple("Non optimizable type");
|
clearSimple("Non optimizable type");
|
||||||
} else {
|
} else {
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ public:
|
|||||||
m_buffersOnly = buffersOnly;
|
m_buffersOnly = buffersOnly;
|
||||||
m_dedupe = dedupe;
|
m_dedupe = dedupe;
|
||||||
// Iterate
|
// Iterate
|
||||||
iterate(nodep);
|
iterateConst(nodep);
|
||||||
// Check results
|
// Check results
|
||||||
if (!m_substTreep) clearSimple("No assignment found\n");
|
if (!m_substTreep) clearSimple("No assignment found\n");
|
||||||
for (GateVarRefList::const_iterator it = m_rhsVarRefs.begin(); it != m_rhsVarRefs.end();
|
for (GateVarRefList::const_iterator it = m_rhsVarRefs.begin(); it != m_rhsVarRefs.end();
|
||||||
@ -1292,7 +1292,7 @@ void GateVisitor::mergeAssigns() {
|
|||||||
//######################################################################
|
//######################################################################
|
||||||
// Find a var's offset in a concatenation
|
// Find a var's offset in a concatenation
|
||||||
|
|
||||||
class GateConcatVisitor final : public VNVisitor {
|
class GateConcatVisitor final : public VNVisitorConst {
|
||||||
private:
|
private:
|
||||||
// STATE
|
// STATE
|
||||||
const AstVarScope* m_vscp = nullptr; // Varscope we're trying to find
|
const AstVarScope* m_vscp = nullptr; // Varscope we're trying to find
|
||||||
@ -1315,11 +1315,11 @@ private:
|
|||||||
}
|
}
|
||||||
void visit(AstConcat* nodep) override {
|
void visit(AstConcat* nodep) override {
|
||||||
UINFO(9, "CLK DECOMP Concat search (off = " << m_offset << ") - " << nodep << endl);
|
UINFO(9, "CLK DECOMP Concat search (off = " << m_offset << ") - " << nodep << endl);
|
||||||
iterate(nodep->rhsp());
|
iterateConst(nodep->rhsp());
|
||||||
iterate(nodep->lhsp());
|
iterateConst(nodep->lhsp());
|
||||||
}
|
}
|
||||||
//--------------------
|
//--------------------
|
||||||
void visit(AstNode* nodep) override { iterateChildren(nodep); }
|
void visit(AstNode* nodep) override { iterateChildrenConst(nodep); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
@ -1331,7 +1331,7 @@ public:
|
|||||||
m_offset = 0;
|
m_offset = 0;
|
||||||
m_found = false;
|
m_found = false;
|
||||||
// Iterate
|
// Iterate
|
||||||
iterate(concatp);
|
iterateConst(concatp);
|
||||||
UINFO(9, "CLK DECOMP Concat Offset (found = " << m_found << ") (" << m_found_offset
|
UINFO(9, "CLK DECOMP Concat Offset (found = " << m_found << ") (" << m_found_offset
|
||||||
<< ") - " << concatp << " : " << vscp
|
<< ") - " << concatp << " : " << vscp
|
||||||
<< endl);
|
<< endl);
|
||||||
|
@ -26,7 +26,7 @@ VL_DEFINE_DEBUG_FUNCTIONS;
|
|||||||
//######################################################################
|
//######################################################################
|
||||||
// Visitor that computes node hashes
|
// Visitor that computes node hashes
|
||||||
|
|
||||||
class HasherVisitor final : public VNVisitor {
|
class HasherVisitor final : public VNVisitorConst {
|
||||||
private:
|
private:
|
||||||
// NODE STATE
|
// NODE STATE
|
||||||
// AstNode::user4() -> V3Hash. Hash value of this node (hash of 0 is illegal)
|
// AstNode::user4() -> V3Hash. Hash value of this node (hash of 0 is illegal)
|
||||||
@ -48,7 +48,8 @@ private:
|
|||||||
// Reset accumulator
|
// Reset accumulator
|
||||||
m_hash = V3Hash{nodep->type()}; // Node type
|
m_hash = V3Hash{nodep->type()}; // Node type
|
||||||
f(); // Node specific hash
|
f(); // Node specific hash
|
||||||
if (hashDType && nodep != nodep->dtypep()) iterateNull(nodep->dtypep()); // Node dtype
|
if (hashDType && nodep != nodep->dtypep())
|
||||||
|
iterateConstNull(nodep->dtypep()); // Node dtype
|
||||||
if (hashChildren) iterateChildrenConst(nodep); // Children
|
if (hashChildren) iterateChildrenConst(nodep); // Children
|
||||||
if (m_cacheInUser4) nodep->user4(m_hash.value());
|
if (m_cacheInUser4) nodep->user4(m_hash.value());
|
||||||
return m_hash;
|
return m_hash;
|
||||||
@ -92,7 +93,7 @@ private:
|
|||||||
// AstNodeDType
|
// AstNodeDType
|
||||||
void visit(AstNodeArrayDType* nodep) override {
|
void visit(AstNodeArrayDType* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() {
|
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() {
|
||||||
iterateNull(nodep->virtRefDTypep());
|
iterateConstNull(nodep->virtRefDTypep());
|
||||||
m_hash += nodep->left();
|
m_hash += nodep->left();
|
||||||
m_hash += nodep->right();
|
m_hash += nodep->right();
|
||||||
});
|
});
|
||||||
@ -120,23 +121,23 @@ private:
|
|||||||
}
|
}
|
||||||
void visit(AstAssocArrayDType* nodep) override {
|
void visit(AstAssocArrayDType* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() {
|
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() {
|
||||||
iterateNull(nodep->virtRefDTypep());
|
iterateConstNull(nodep->virtRefDTypep());
|
||||||
iterateNull(nodep->virtRefDType2p());
|
iterateConstNull(nodep->virtRefDType2p());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstDynArrayDType* nodep) override {
|
void visit(AstDynArrayDType* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
||||||
iterateNull(nodep->virtRefDTypep());
|
iterateConstNull(nodep->virtRefDTypep());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstUnsizedArrayDType* nodep) override {
|
void visit(AstUnsizedArrayDType* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
||||||
iterateNull(nodep->virtRefDTypep());
|
iterateConstNull(nodep->virtRefDTypep());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstWildcardArrayDType* nodep) override {
|
void visit(AstWildcardArrayDType* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
||||||
iterateNull(nodep->virtRefDTypep());
|
iterateConstNull(nodep->virtRefDTypep());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstBasicDType* nodep) override {
|
void visit(AstBasicDType* nodep) override {
|
||||||
@ -148,29 +149,29 @@ private:
|
|||||||
}
|
}
|
||||||
void visit(AstConstDType* nodep) override {
|
void visit(AstConstDType* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { //
|
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { //
|
||||||
iterateNull(nodep->virtRefDTypep());
|
iterateConstNull(nodep->virtRefDTypep());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstClassRefDType* nodep) override {
|
void visit(AstClassRefDType* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
||||||
iterateNull(nodep->classp());
|
iterateConstNull(nodep->classp());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstIfaceRefDType* nodep) override {
|
void visit(AstIfaceRefDType* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
||||||
iterateNull(nodep->cellp());
|
iterateConstNull(nodep->cellp());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstQueueDType* nodep) override {
|
void visit(AstQueueDType* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
||||||
iterateNull(nodep->virtRefDTypep());
|
iterateConstNull(nodep->virtRefDTypep());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstRefDType* nodep) override {
|
void visit(AstRefDType* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() {
|
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() {
|
||||||
m_hash += nodep->name();
|
m_hash += nodep->name();
|
||||||
iterateNull(nodep->typedefp());
|
iterateConstNull(nodep->typedefp());
|
||||||
iterateNull(nodep->refDTypep());
|
iterateConstNull(nodep->refDTypep());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstVoidDType* nodep) override {
|
void visit(AstVoidDType* nodep) override {
|
||||||
@ -203,16 +204,16 @@ private:
|
|||||||
void visit(AstVarRef* nodep) override {
|
void visit(AstVarRef* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {
|
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {
|
||||||
if (nodep->varScopep()) {
|
if (nodep->varScopep()) {
|
||||||
iterateNull(nodep->varScopep());
|
iterateConstNull(nodep->varScopep());
|
||||||
} else {
|
} else {
|
||||||
iterateNull(nodep->varp());
|
iterateConstNull(nodep->varp());
|
||||||
m_hash += nodep->selfPointer();
|
m_hash += nodep->selfPointer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstVarXRef* nodep) override {
|
void visit(AstVarXRef* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {
|
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {
|
||||||
iterateNull(nodep->varp());
|
iterateConstNull(nodep->varp());
|
||||||
m_hash += nodep->dotted();
|
m_hash += nodep->dotted();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -233,7 +234,7 @@ private:
|
|||||||
}
|
}
|
||||||
void visit(AstAddrOfCFunc* nodep) override {
|
void visit(AstAddrOfCFunc* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { //
|
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { //
|
||||||
iterateNull(nodep->funcp());
|
iterateConstNull(nodep->funcp());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,13 +250,13 @@ private:
|
|||||||
}
|
}
|
||||||
void visit(AstNodeCCall* nodep) override {
|
void visit(AstNodeCCall* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
||||||
iterateNull(nodep->funcp());
|
iterateConstNull(nodep->funcp());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstNodeFTaskRef* nodep) override {
|
void visit(AstNodeFTaskRef* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() {
|
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() {
|
||||||
iterateNull(nodep->taskp());
|
iterateConstNull(nodep->taskp());
|
||||||
iterateNull(nodep->classOrPackagep());
|
iterateConstNull(nodep->classOrPackagep());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstCMethodHard* nodep) override {
|
void visit(AstCMethodHard* nodep) override {
|
||||||
@ -265,12 +266,12 @@ private:
|
|||||||
}
|
}
|
||||||
void visit(AstCAwait* nodep) override {
|
void visit(AstCAwait* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { //
|
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { //
|
||||||
iterateNull(nodep->sensesp());
|
iterateConstNull(nodep->sensesp());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstCoverInc* nodep) override {
|
void visit(AstCoverInc* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
||||||
iterateNull(nodep->declp());
|
iterateConstNull(nodep->declp());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstDisplay* nodep) override {
|
void visit(AstDisplay* nodep) override {
|
||||||
@ -285,12 +286,12 @@ private:
|
|||||||
}
|
}
|
||||||
void visit(AstJumpGo* nodep) override {
|
void visit(AstJumpGo* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
||||||
iterateNull(nodep->labelp());
|
iterateConstNull(nodep->labelp());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstTraceInc* nodep) override {
|
void visit(AstTraceInc* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { //
|
||||||
iterateNull(nodep->declp());
|
iterateConstNull(nodep->declp());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstNodeCoverOrAssert* nodep) override {
|
void visit(AstNodeCoverOrAssert* nodep) override {
|
||||||
@ -332,7 +333,7 @@ private:
|
|||||||
}
|
}
|
||||||
void visit(AstClassOrPackageRef* nodep) override {
|
void visit(AstClassOrPackageRef* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { //
|
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { //
|
||||||
iterateNull(nodep->classOrPackageNodep());
|
iterateConstNull(nodep->classOrPackageNodep());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstSenItem* nodep) override {
|
void visit(AstSenItem* nodep) override {
|
||||||
@ -376,7 +377,7 @@ private:
|
|||||||
if (dtypep) {
|
if (dtypep) {
|
||||||
const uint32_t size = dtypep->elementsConst();
|
const uint32_t size = dtypep->elementsConst();
|
||||||
for (uint32_t n = 0; n < size; ++n) { //
|
for (uint32_t n = 0; n < size; ++n) { //
|
||||||
iterateNull(nodep->getIndexDefaultedValuep(n));
|
iterateConstNull(nodep->getIndexDefaultedValuep(n));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -417,13 +418,13 @@ private:
|
|||||||
void visit(AstScope* nodep) override {
|
void visit(AstScope* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, false, [=]() {
|
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, false, [=]() {
|
||||||
m_hash += nodep->name();
|
m_hash += nodep->name();
|
||||||
iterateNull(nodep->aboveScopep());
|
iterateConstNull(nodep->aboveScopep());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstVarScope* nodep) override {
|
void visit(AstVarScope* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {
|
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {
|
||||||
iterateNull(nodep->varp());
|
iterateConstNull(nodep->varp());
|
||||||
iterateNull(nodep->scopep());
|
iterateConstNull(nodep->scopep());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstEnumItem* nodep) override {
|
void visit(AstEnumItem* nodep) override {
|
||||||
@ -443,19 +444,19 @@ private:
|
|||||||
}
|
}
|
||||||
void visit(AstActive* nodep) override {
|
void visit(AstActive* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { //
|
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { //
|
||||||
iterateNull(nodep->sensesp());
|
iterateConstNull(nodep->sensesp());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstCell* nodep) override {
|
void visit(AstCell* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {
|
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {
|
||||||
m_hash += nodep->name();
|
m_hash += nodep->name();
|
||||||
iterateNull(nodep->modp());
|
iterateConstNull(nodep->modp());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstCellInline* nodep) override {
|
void visit(AstCellInline* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {
|
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {
|
||||||
m_hash += nodep->name();
|
m_hash += nodep->name();
|
||||||
iterateNull(nodep->scopep());
|
iterateConstNull(nodep->scopep());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstNodeFTask* nodep) override {
|
void visit(AstNodeFTask* nodep) override {
|
||||||
@ -471,13 +472,13 @@ private:
|
|||||||
void visit(AstModportVarRef* nodep) override {
|
void visit(AstModportVarRef* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {
|
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {
|
||||||
m_hash += nodep->name();
|
m_hash += nodep->name();
|
||||||
iterateNull(nodep->varp());
|
iterateConstNull(nodep->varp());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstModportFTaskRef* nodep) override {
|
void visit(AstModportFTaskRef* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {
|
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {
|
||||||
m_hash += nodep->name();
|
m_hash += nodep->name();
|
||||||
iterateNull(nodep->ftaskp());
|
iterateConstNull(nodep->ftaskp());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstMTaskBody* nodep) override {
|
void visit(AstMTaskBody* nodep) override {
|
||||||
@ -502,12 +503,12 @@ public:
|
|||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
explicit HasherVisitor(AstNode* nodep)
|
explicit HasherVisitor(AstNode* nodep)
|
||||||
: m_cacheInUser4{true} {
|
: m_cacheInUser4{true} {
|
||||||
iterate(nodep);
|
iterateConst(nodep);
|
||||||
}
|
}
|
||||||
class Uncached {};
|
class Uncached {};
|
||||||
HasherVisitor(const AstNode* nodep, Uncached)
|
HasherVisitor(const AstNode* nodep, Uncached)
|
||||||
: m_cacheInUser4{false} {
|
: m_cacheInUser4{false} {
|
||||||
iterate(const_cast<AstNode*>(nodep));
|
iterateConst(const_cast<AstNode*>(nodep));
|
||||||
}
|
}
|
||||||
V3Hash finalHash() const { return m_hash; }
|
V3Hash finalHash() const { return m_hash; }
|
||||||
~HasherVisitor() override = default;
|
~HasherVisitor() override = default;
|
||||||
|
@ -139,7 +139,7 @@ public:
|
|||||||
|
|
||||||
//######################################################################
|
//######################################################################
|
||||||
|
|
||||||
class InstDeModVarVisitor final : public VNVisitor {
|
class InstDeModVarVisitor final : public VNVisitorConst {
|
||||||
// Expand all module variables, and save names for later reference
|
// Expand all module variables, and save names for later reference
|
||||||
private:
|
private:
|
||||||
// STATE
|
// STATE
|
||||||
@ -151,10 +151,10 @@ private:
|
|||||||
UINFO(8, " dm-1-VAR " << nodep << endl);
|
UINFO(8, " dm-1-VAR " << nodep << endl);
|
||||||
insert(nodep);
|
insert(nodep);
|
||||||
}
|
}
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstNodeExpr*) override {} // Accelerate
|
void visit(AstNodeExpr*) override {} // Accelerate
|
||||||
void visit(AstNode* nodep) override { iterateChildren(nodep); }
|
void visit(AstNode* nodep) override { iterateChildrenConst(nodep); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// METHODS
|
// METHODS
|
||||||
@ -182,7 +182,7 @@ public:
|
|||||||
void main(AstNodeModule* nodep) {
|
void main(AstNodeModule* nodep) {
|
||||||
UINFO(8, " dmMODULE " << nodep << endl);
|
UINFO(8, " dmMODULE " << nodep << endl);
|
||||||
m_modVarNameMap.clear();
|
m_modVarNameMap.clear();
|
||||||
iterate(nodep);
|
iterateConst(nodep);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ VL_DEFINE_DEBUG_FUNCTIONS;
|
|||||||
/// we'll count instructions from either the 'if' or the 'else' branch,
|
/// we'll count instructions from either the 'if' or the 'else' branch,
|
||||||
/// whichever is larger. We know we won't run both.
|
/// whichever is larger. We know we won't run both.
|
||||||
|
|
||||||
class InstrCountVisitor final : public VNVisitor {
|
class InstrCountVisitor final : public VNVisitorConst {
|
||||||
private:
|
private:
|
||||||
// NODE STATE
|
// NODE STATE
|
||||||
// AstNode::user4() -> int. Path cost + 1, 0 means don't dump
|
// AstNode::user4() -> int. Path cost + 1, 0 means don't dump
|
||||||
@ -76,7 +76,7 @@ public:
|
|||||||
: m_startNodep{nodep}
|
: m_startNodep{nodep}
|
||||||
, m_assertNoDups{assertNoDups}
|
, m_assertNoDups{assertNoDups}
|
||||||
, m_osp{osp} {
|
, m_osp{osp} {
|
||||||
if (nodep) iterate(nodep);
|
if (nodep) iterateConst(nodep);
|
||||||
}
|
}
|
||||||
~InstrCountVisitor() override = default;
|
~InstrCountVisitor() override = default;
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ private:
|
|||||||
// Hence, exclude the child of the AstWordSel from the computation,
|
// Hence, exclude the child of the AstWordSel from the computation,
|
||||||
// whose cost scales with the size of the entire (maybe large) vector.
|
// whose cost scales with the size of the entire (maybe large) vector.
|
||||||
const VisitBase vb{this, nodep};
|
const VisitBase vb{this, nodep};
|
||||||
iterateAndNextNull(nodep->bitp());
|
iterateAndNextConstNull(nodep->bitp());
|
||||||
}
|
}
|
||||||
void visit(AstSel* nodep) override {
|
void visit(AstSel* nodep) override {
|
||||||
if (m_ignoreRemaining) return;
|
if (m_ignoreRemaining) return;
|
||||||
@ -144,8 +144,8 @@ private:
|
|||||||
// its width) and the cost of the lsbp() and widthp() nodes, but not
|
// its width) and the cost of the lsbp() and widthp() nodes, but not
|
||||||
// the fromp() node which could be disproportionately large.
|
// the fromp() node which could be disproportionately large.
|
||||||
const VisitBase vb{this, nodep};
|
const VisitBase vb{this, nodep};
|
||||||
iterateAndNextNull(nodep->lsbp());
|
iterateAndNextConstNull(nodep->lsbp());
|
||||||
iterateAndNextNull(nodep->widthp());
|
iterateAndNextConstNull(nodep->widthp());
|
||||||
}
|
}
|
||||||
void visit(AstSliceSel* nodep) override { // LCOV_EXCL_LINE
|
void visit(AstSliceSel* nodep) override { // LCOV_EXCL_LINE
|
||||||
nodep->v3fatalSrc("AstSliceSel unhandled");
|
nodep->v3fatalSrc("AstSliceSel unhandled");
|
||||||
@ -177,18 +177,18 @@ private:
|
|||||||
void visit(AstNodeIf* nodep) override {
|
void visit(AstNodeIf* nodep) override {
|
||||||
if (m_ignoreRemaining) return;
|
if (m_ignoreRemaining) return;
|
||||||
const VisitBase vb{this, nodep};
|
const VisitBase vb{this, nodep};
|
||||||
iterateAndNextNull(nodep->condp());
|
iterateAndNextConstNull(nodep->condp());
|
||||||
const uint32_t savedCount = m_instrCount;
|
const uint32_t savedCount = m_instrCount;
|
||||||
|
|
||||||
UINFO(8, "thensp:\n");
|
UINFO(8, "thensp:\n");
|
||||||
reset();
|
reset();
|
||||||
iterateAndNextNull(nodep->thensp());
|
iterateAndNextConstNull(nodep->thensp());
|
||||||
uint32_t ifCount = m_instrCount;
|
uint32_t ifCount = m_instrCount;
|
||||||
if (nodep->branchPred().unlikely()) ifCount = 0;
|
if (nodep->branchPred().unlikely()) ifCount = 0;
|
||||||
|
|
||||||
UINFO(8, "elsesp:\n");
|
UINFO(8, "elsesp:\n");
|
||||||
reset();
|
reset();
|
||||||
iterateAndNextNull(nodep->elsesp());
|
iterateAndNextConstNull(nodep->elsesp());
|
||||||
uint32_t elseCount = m_instrCount;
|
uint32_t elseCount = m_instrCount;
|
||||||
if (nodep->branchPred().likely()) elseCount = 0;
|
if (nodep->branchPred().likely()) elseCount = 0;
|
||||||
|
|
||||||
@ -206,17 +206,17 @@ private:
|
|||||||
// Just like if/else above, the ternary operator only evaluates
|
// Just like if/else above, the ternary operator only evaluates
|
||||||
// one of the two expressions, so only count the max.
|
// one of the two expressions, so only count the max.
|
||||||
const VisitBase vb{this, nodep};
|
const VisitBase vb{this, nodep};
|
||||||
iterateAndNextNull(nodep->condp());
|
iterateAndNextConstNull(nodep->condp());
|
||||||
const uint32_t savedCount = m_instrCount;
|
const uint32_t savedCount = m_instrCount;
|
||||||
|
|
||||||
UINFO(8, "?\n");
|
UINFO(8, "?\n");
|
||||||
reset();
|
reset();
|
||||||
iterateAndNextNull(nodep->thenp());
|
iterateAndNextConstNull(nodep->thenp());
|
||||||
const uint32_t ifCount = m_instrCount;
|
const uint32_t ifCount = m_instrCount;
|
||||||
|
|
||||||
UINFO(8, ":\n");
|
UINFO(8, ":\n");
|
||||||
reset();
|
reset();
|
||||||
iterateAndNextNull(nodep->elsep());
|
iterateAndNextConstNull(nodep->elsep());
|
||||||
const uint32_t elseCount = m_instrCount;
|
const uint32_t elseCount = m_instrCount;
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
@ -230,7 +230,7 @@ private:
|
|||||||
}
|
}
|
||||||
void visit(AstCAwait* nodep) override {
|
void visit(AstCAwait* nodep) override {
|
||||||
if (m_ignoreRemaining) return;
|
if (m_ignoreRemaining) return;
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
// Anything past a co_await is irrelevant
|
// Anything past a co_await is irrelevant
|
||||||
m_ignoreRemaining = true;
|
m_ignoreRemaining = true;
|
||||||
}
|
}
|
||||||
@ -241,7 +241,7 @@ private:
|
|||||||
// Sum counts in each statement until the first await
|
// Sum counts in each statement until the first await
|
||||||
for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) {
|
for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) {
|
||||||
reset();
|
reset();
|
||||||
iterate(stmtp);
|
iterateConst(stmtp);
|
||||||
totalCount += m_instrCount;
|
totalCount += m_instrCount;
|
||||||
}
|
}
|
||||||
m_instrCount = totalCount;
|
m_instrCount = totalCount;
|
||||||
@ -266,9 +266,9 @@ private:
|
|||||||
void visit(AstNodeCCall* nodep) override {
|
void visit(AstNodeCCall* nodep) override {
|
||||||
if (m_ignoreRemaining) return;
|
if (m_ignoreRemaining) return;
|
||||||
const VisitBase vb{this, nodep};
|
const VisitBase vb{this, nodep};
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
m_tracingCall = true;
|
m_tracingCall = true;
|
||||||
iterate(nodep->funcp());
|
iterateConst(nodep->funcp());
|
||||||
UASSERT_OBJ(!m_tracingCall, nodep, "visit(AstCFunc) should have cleared m_tracingCall.");
|
UASSERT_OBJ(!m_tracingCall, nodep, "visit(AstCFunc) should have cleared m_tracingCall.");
|
||||||
}
|
}
|
||||||
void visit(AstCFunc* nodep) override {
|
void visit(AstCFunc* nodep) override {
|
||||||
@ -282,21 +282,21 @@ private:
|
|||||||
{
|
{
|
||||||
m_inCFunc = true;
|
m_inCFunc = true;
|
||||||
const VisitBase vb{this, nodep};
|
const VisitBase vb{this, nodep};
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
m_ignoreRemaining = false;
|
m_ignoreRemaining = false;
|
||||||
}
|
}
|
||||||
void visit(AstNode* nodep) override {
|
void visit(AstNode* nodep) override {
|
||||||
if (m_ignoreRemaining) return;
|
if (m_ignoreRemaining) return;
|
||||||
const VisitBase vb{this, nodep};
|
const VisitBase vb{this, nodep};
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
|
|
||||||
VL_UNCOPYABLE(InstrCountVisitor);
|
VL_UNCOPYABLE(InstrCountVisitor);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Iterate the graph printing the critical path marked by previous visitation
|
// Iterate the graph printing the critical path marked by previous visitation
|
||||||
class InstrCountDumpVisitor final : public VNVisitor {
|
class InstrCountDumpVisitor final : public VNVisitorConst {
|
||||||
private:
|
private:
|
||||||
// NODE STATE
|
// NODE STATE
|
||||||
// AstNode::user4() -> int. Path cost, 0 means don't dump
|
// AstNode::user4() -> int. Path cost, 0 means don't dump
|
||||||
@ -311,7 +311,7 @@ public:
|
|||||||
: m_osp{osp} {
|
: m_osp{osp} {
|
||||||
// No check for nullptr output, so...
|
// No check for nullptr output, so...
|
||||||
UASSERT_OBJ(osp, nodep, "Don't call if not dumping");
|
UASSERT_OBJ(osp, nodep, "Don't call if not dumping");
|
||||||
if (nodep) iterate(nodep);
|
if (nodep) iterateConst(nodep);
|
||||||
}
|
}
|
||||||
~InstrCountDumpVisitor() override = default;
|
~InstrCountDumpVisitor() override = default;
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ private:
|
|||||||
if (unsigned costPlus1 = nodep->user4()) {
|
if (unsigned costPlus1 = nodep->user4()) {
|
||||||
*m_osp << " " << indent() << "cost " << std::setw(6) << std::left << (costPlus1 - 1)
|
*m_osp << " " << indent() << "cost " << std::setw(6) << std::left << (costPlus1 - 1)
|
||||||
<< " " << nodep << '\n';
|
<< " " << nodep << '\n';
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
--m_depth;
|
--m_depth;
|
||||||
}
|
}
|
||||||
|
@ -446,7 +446,7 @@ public:
|
|||||||
// Recurses cells backwards, so we can pick up those things that propagate
|
// Recurses cells backwards, so we can pick up those things that propagate
|
||||||
// from child cells up to the top module.
|
// from child cells up to the top module.
|
||||||
|
|
||||||
class LinkBotupVisitor final : public VNVisitor {
|
class LinkBotupVisitor final : public VNVisitorConst {
|
||||||
private:
|
private:
|
||||||
// STATE
|
// STATE
|
||||||
AstNodeModule* m_modp = nullptr; // Current module
|
AstNodeModule* m_modp = nullptr; // Current module
|
||||||
@ -458,10 +458,8 @@ private:
|
|||||||
}
|
}
|
||||||
void visit(AstNodeModule* nodep) override {
|
void visit(AstNodeModule* nodep) override {
|
||||||
VL_RESTORER(m_modp);
|
VL_RESTORER(m_modp);
|
||||||
{
|
m_modp = nodep;
|
||||||
m_modp = nodep;
|
iterateChildrenConst(nodep);
|
||||||
iterateChildren(nodep);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void visit(AstCell* nodep) override {
|
void visit(AstCell* nodep) override {
|
||||||
// Parent module inherits child's publicity
|
// Parent module inherits child's publicity
|
||||||
@ -469,11 +467,11 @@ private:
|
|||||||
//** No iteration for speed
|
//** No iteration for speed
|
||||||
}
|
}
|
||||||
void visit(AstNodeExpr*) override {} // Accelerate
|
void visit(AstNodeExpr*) override {} // Accelerate
|
||||||
void visit(AstNode* nodep) override { iterateChildren(nodep); }
|
void visit(AstNode* nodep) override { iterateChildrenConst(nodep); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
explicit LinkBotupVisitor(AstNetlist* rootp) { iterate(rootp); }
|
explicit LinkBotupVisitor(AstNetlist* rootp) { iterateConst(rootp); }
|
||||||
~LinkBotupVisitor() override = default;
|
~LinkBotupVisitor() override = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ using StmtPropertiesAllocator = AstUser3Allocator<AstNodeStmt, StmtProperties>;
|
|||||||
|
|
||||||
// Pure analysis visitor that build the StmtProperties for each statement in the given
|
// Pure analysis visitor that build the StmtProperties for each statement in the given
|
||||||
// AstNode list (following AstNode::nextp())
|
// AstNode list (following AstNode::nextp())
|
||||||
class CodeMotionAnalysisVisitor final : public VNVisitor {
|
class CodeMotionAnalysisVisitor final : public VNVisitorConst {
|
||||||
// NODE STATE
|
// NODE STATE
|
||||||
// AstNodeStmt::user3 -> StmtProperties (accessed via m_stmtProperties, managed externally,
|
// AstNodeStmt::user3 -> StmtProperties (accessed via m_stmtProperties, managed externally,
|
||||||
// see MergeCondVisitor::process)
|
// see MergeCondVisitor::process)
|
||||||
|
@ -36,7 +36,7 @@ VL_DEFINE_DEBUG_FUNCTIONS;
|
|||||||
//######################################################################
|
//######################################################################
|
||||||
// Visitor that marks classes needing a randomize() method
|
// Visitor that marks classes needing a randomize() method
|
||||||
|
|
||||||
class RandomizeMarkVisitor final : public VNVisitor {
|
class RandomizeMarkVisitor final : public VNVisitorConst {
|
||||||
private:
|
private:
|
||||||
// NODE STATE
|
// NODE STATE
|
||||||
// Cleared on Netlist
|
// Cleared on Netlist
|
||||||
@ -87,7 +87,7 @@ private:
|
|||||||
|
|
||||||
// VISITORS
|
// VISITORS
|
||||||
void visit(AstClass* nodep) override {
|
void visit(AstClass* nodep) override {
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
if (nodep->extendsp()) {
|
if (nodep->extendsp()) {
|
||||||
// Save pointer to derived class
|
// Save pointer to derived class
|
||||||
AstClass* const basep = nodep->extendsp()->classp();
|
AstClass* const basep = nodep->extendsp()->classp();
|
||||||
@ -95,7 +95,7 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void visit(AstMethodCall* nodep) override {
|
void visit(AstMethodCall* nodep) override {
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
if (nodep->name() != "randomize") return;
|
if (nodep->name() != "randomize") return;
|
||||||
if (const AstClassRefDType* const classRefp
|
if (const AstClassRefDType* const classRefp
|
||||||
= VN_CAST(nodep->fromp()->dtypep(), ClassRefDType)) {
|
= VN_CAST(nodep->fromp()->dtypep(), ClassRefDType)) {
|
||||||
@ -105,12 +105,12 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit(AstNode* nodep) override { iterateChildren(nodep); }
|
void visit(AstNode* nodep) override { iterateChildrenConst(nodep); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
explicit RandomizeMarkVisitor(AstNetlist* nodep) {
|
explicit RandomizeMarkVisitor(AstNetlist* nodep) {
|
||||||
iterate(nodep);
|
iterateConst(nodep);
|
||||||
markAllDerived();
|
markAllDerived();
|
||||||
}
|
}
|
||||||
~RandomizeMarkVisitor() override = default;
|
~RandomizeMarkVisitor() override = default;
|
||||||
|
118
src/V3Simulate.h
118
src/V3Simulate.h
@ -64,7 +64,7 @@ public:
|
|||||||
~SimStackNode() = default;
|
~SimStackNode() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SimulateVisitor VL_NOT_FINAL : public VNVisitor {
|
class SimulateVisitor VL_NOT_FINAL : public VNVisitorConst {
|
||||||
// Simulate a node tree, returning value of variables
|
// Simulate a node tree, returning value of variables
|
||||||
// Two major operating modes:
|
// Two major operating modes:
|
||||||
// Test the tree to see if it is conformant
|
// Test the tree to see if it is conformant
|
||||||
@ -400,7 +400,7 @@ private:
|
|||||||
void visit(AstAlways* nodep) override {
|
void visit(AstAlways* nodep) override {
|
||||||
if (jumpingOver(nodep)) return;
|
if (jumpingOver(nodep)) return;
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstSenTree* nodep) override {
|
void visit(AstSenTree* nodep) override {
|
||||||
// Sensitivities aren't inputs per se; we'll keep our tree under the same sens.
|
// Sensitivities aren't inputs per se; we'll keep our tree under the same sens.
|
||||||
@ -409,7 +409,7 @@ private:
|
|||||||
if (jumpingOver(nodep)) return;
|
if (jumpingOver(nodep)) return;
|
||||||
if (!optimizable()) return; // Accelerate
|
if (!optimizable()) return; // Accelerate
|
||||||
UASSERT_OBJ(nodep->varp(), nodep, "Unlinked");
|
UASSERT_OBJ(nodep->varp(), nodep, "Unlinked");
|
||||||
iterateChildren(nodep->varp());
|
iterateChildrenConst(nodep->varp());
|
||||||
AstNode* const vscp = varOrScope(nodep);
|
AstNode* const vscp = varOrScope(nodep);
|
||||||
|
|
||||||
// We can't have non-delayed assignments with same value on LHS and RHS
|
// We can't have non-delayed assignments with same value on LHS and RHS
|
||||||
@ -502,7 +502,7 @@ private:
|
|||||||
clearOptimizable(nodep, "Constant function called under generate");
|
clearOptimizable(nodep, "Constant function called under generate");
|
||||||
}
|
}
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstInitialStatic* nodep) override {
|
void visit(AstInitialStatic* nodep) override {
|
||||||
if (jumpingOver(nodep)) return;
|
if (jumpingOver(nodep)) return;
|
||||||
@ -511,21 +511,21 @@ private:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstNodeIf* nodep) override {
|
void visit(AstNodeIf* nodep) override {
|
||||||
if (jumpingOver(nodep)) return;
|
if (jumpingOver(nodep)) return;
|
||||||
UINFO(5, " IF " << nodep << endl);
|
UINFO(5, " IF " << nodep << endl);
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
if (m_checkOnly) {
|
if (m_checkOnly) {
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
} else {
|
} else {
|
||||||
iterateAndNextNull(nodep->condp());
|
iterateAndNextConstNull(nodep->condp());
|
||||||
if (optimizable()) {
|
if (optimizable()) {
|
||||||
if (fetchConst(nodep->condp())->num().isNeqZero()) {
|
if (fetchConst(nodep->condp())->num().isNeqZero()) {
|
||||||
iterateAndNextNull(nodep->thensp());
|
iterateAndNextConstNull(nodep->thensp());
|
||||||
} else {
|
} else {
|
||||||
iterateAndNextNull(nodep->elsesp());
|
iterateAndNextConstNull(nodep->elsesp());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -544,7 +544,7 @@ private:
|
|||||||
if (!m_checkOnly && optimizable()) {
|
if (!m_checkOnly && optimizable()) {
|
||||||
AstNode* const valuep = nodep->itemp()->valuep();
|
AstNode* const valuep = nodep->itemp()->valuep();
|
||||||
if (valuep) {
|
if (valuep) {
|
||||||
iterateAndNextNull(valuep);
|
iterateAndNextConstNull(valuep);
|
||||||
if (optimizable()) newValue(nodep, fetchValue(valuep));
|
if (optimizable()) newValue(nodep, fetchValue(valuep));
|
||||||
} else {
|
} else {
|
||||||
clearOptimizable(nodep, "No value found for enum item"); // LCOV_EXCL_LINE
|
clearOptimizable(nodep, "No value found for enum item"); // LCOV_EXCL_LINE
|
||||||
@ -554,7 +554,7 @@ private:
|
|||||||
void visit(AstNodeUniop* nodep) override {
|
void visit(AstNodeUniop* nodep) override {
|
||||||
if (!optimizable()) return; // Accelerate
|
if (!optimizable()) return; // Accelerate
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
if (!m_checkOnly && optimizable()) {
|
if (!m_checkOnly && optimizable()) {
|
||||||
nodep->numberOperate(newConst(nodep)->num(), fetchConst(nodep->lhsp())->num());
|
nodep->numberOperate(newConst(nodep)->num(), fetchConst(nodep->lhsp())->num());
|
||||||
}
|
}
|
||||||
@ -562,7 +562,7 @@ private:
|
|||||||
void visit(AstNodeBiop* nodep) override {
|
void visit(AstNodeBiop* nodep) override {
|
||||||
if (!optimizable()) return; // Accelerate
|
if (!optimizable()) return; // Accelerate
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
if (!m_checkOnly && optimizable()) {
|
if (!m_checkOnly && optimizable()) {
|
||||||
nodep->numberOperate(newConst(nodep)->num(), fetchConst(nodep->lhsp())->num(),
|
nodep->numberOperate(newConst(nodep)->num(), fetchConst(nodep->lhsp())->num(),
|
||||||
fetchConst(nodep->rhsp())->num());
|
fetchConst(nodep->rhsp())->num());
|
||||||
@ -571,7 +571,7 @@ private:
|
|||||||
void visit(AstNodeTriop* nodep) override {
|
void visit(AstNodeTriop* nodep) override {
|
||||||
if (!optimizable()) return; // Accelerate
|
if (!optimizable()) return; // Accelerate
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
if (!m_checkOnly && optimizable()) {
|
if (!m_checkOnly && optimizable()) {
|
||||||
nodep->numberOperate(newConst(nodep)->num(), fetchConst(nodep->lhsp())->num(),
|
nodep->numberOperate(newConst(nodep)->num(), fetchConst(nodep->lhsp())->num(),
|
||||||
fetchConst(nodep->rhsp())->num(),
|
fetchConst(nodep->rhsp())->num(),
|
||||||
@ -581,7 +581,7 @@ private:
|
|||||||
void visit(AstNodeQuadop* nodep) override {
|
void visit(AstNodeQuadop* nodep) override {
|
||||||
if (!optimizable()) return; // Accelerate
|
if (!optimizable()) return; // Accelerate
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
if (!m_checkOnly && optimizable()) {
|
if (!m_checkOnly && optimizable()) {
|
||||||
nodep->numberOperate(newConst(nodep)->num(), fetchConst(nodep->lhsp())->num(),
|
nodep->numberOperate(newConst(nodep)->num(), fetchConst(nodep->lhsp())->num(),
|
||||||
fetchConst(nodep->rhsp())->num(),
|
fetchConst(nodep->rhsp())->num(),
|
||||||
@ -594,12 +594,12 @@ private:
|
|||||||
if (!optimizable()) return; // Accelerate
|
if (!optimizable()) return; // Accelerate
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
if (m_checkOnly) {
|
if (m_checkOnly) {
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
} else {
|
} else {
|
||||||
iterate(nodep->lhsp());
|
iterateConst(nodep->lhsp());
|
||||||
if (optimizable()) {
|
if (optimizable()) {
|
||||||
if (fetchConst(nodep->lhsp())->num().isNeqZero()) {
|
if (fetchConst(nodep->lhsp())->num().isNeqZero()) {
|
||||||
iterate(nodep->rhsp());
|
iterateConst(nodep->rhsp());
|
||||||
newValue(nodep, fetchValue(nodep->rhsp()));
|
newValue(nodep, fetchValue(nodep->rhsp()));
|
||||||
} else {
|
} else {
|
||||||
newValue(nodep, fetchValue(nodep->lhsp())); // a zero
|
newValue(nodep, fetchValue(nodep->lhsp())); // a zero
|
||||||
@ -612,14 +612,14 @@ private:
|
|||||||
if (!optimizable()) return; // Accelerate
|
if (!optimizable()) return; // Accelerate
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
if (m_checkOnly) {
|
if (m_checkOnly) {
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
} else {
|
} else {
|
||||||
iterate(nodep->lhsp());
|
iterateConst(nodep->lhsp());
|
||||||
if (optimizable()) {
|
if (optimizable()) {
|
||||||
if (fetchConst(nodep->lhsp())->num().isNeqZero()) {
|
if (fetchConst(nodep->lhsp())->num().isNeqZero()) {
|
||||||
newValue(nodep, fetchValue(nodep->lhsp())); // a one
|
newValue(nodep, fetchValue(nodep->lhsp())); // a one
|
||||||
} else {
|
} else {
|
||||||
iterate(nodep->rhsp());
|
iterateConst(nodep->rhsp());
|
||||||
newValue(nodep, fetchValue(nodep->rhsp()));
|
newValue(nodep, fetchValue(nodep->rhsp()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -630,16 +630,16 @@ private:
|
|||||||
if (!optimizable()) return; // Accelerate
|
if (!optimizable()) return; // Accelerate
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
if (m_checkOnly) {
|
if (m_checkOnly) {
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
} else {
|
} else {
|
||||||
iterate(nodep->lhsp());
|
iterateConst(nodep->lhsp());
|
||||||
if (optimizable()) {
|
if (optimizable()) {
|
||||||
if (fetchConst(nodep->lhsp())->num().isEqZero()) {
|
if (fetchConst(nodep->lhsp())->num().isEqZero()) {
|
||||||
const AstConst cnst{nodep->fileline(), AstConst::WidthedValue{}, 1,
|
const AstConst cnst{nodep->fileline(), AstConst::WidthedValue{}, 1,
|
||||||
1}; // a one
|
1}; // a one
|
||||||
newValue(nodep, &cnst); // a one
|
newValue(nodep, &cnst); // a one
|
||||||
} else {
|
} else {
|
||||||
iterate(nodep->rhsp());
|
iterateConst(nodep->rhsp());
|
||||||
newValue(nodep, fetchValue(nodep->rhsp()));
|
newValue(nodep, fetchValue(nodep->rhsp()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -652,15 +652,15 @@ private:
|
|||||||
if (!optimizable()) return; // Accelerate
|
if (!optimizable()) return; // Accelerate
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
if (m_checkOnly) {
|
if (m_checkOnly) {
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
} else {
|
} else {
|
||||||
iterate(nodep->condp());
|
iterateConst(nodep->condp());
|
||||||
if (optimizable()) {
|
if (optimizable()) {
|
||||||
if (fetchConst(nodep->condp())->num().isNeqZero()) {
|
if (fetchConst(nodep->condp())->num().isNeqZero()) {
|
||||||
iterate(nodep->thenp());
|
iterateConst(nodep->thenp());
|
||||||
newValue(nodep, fetchValue(nodep->thenp()));
|
newValue(nodep, fetchValue(nodep->thenp()));
|
||||||
} else {
|
} else {
|
||||||
iterate(nodep->elsep());
|
iterateConst(nodep->elsep());
|
||||||
newValue(nodep, fetchValue(nodep->elsep()));
|
newValue(nodep, fetchValue(nodep->elsep()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -668,11 +668,11 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void handleAssignArray(AstNodeAssign* nodep, AstArraySel* selp) {
|
void handleAssignArray(AstNodeAssign* nodep, AstArraySel* selp) {
|
||||||
iterateAndNextNull(nodep->rhsp()); // Value to assign
|
iterateAndNextConstNull(nodep->rhsp()); // Value to assign
|
||||||
// At present we only handle single dimensional assignments
|
// At present we only handle single dimensional assignments
|
||||||
// To do better, we need the concept of lvalues, or similar, to know where/how to insert
|
// To do better, we need the concept of lvalues, or similar, to know where/how to insert
|
||||||
checkNodeInfo(selp);
|
checkNodeInfo(selp);
|
||||||
iterateAndNextNull(selp->bitp()); // Bit index
|
iterateAndNextConstNull(selp->bitp()); // Bit index
|
||||||
AstVarRef* const varrefp = VN_CAST(selp->fromp(), VarRef);
|
AstVarRef* const varrefp = VN_CAST(selp->fromp(), VarRef);
|
||||||
if (!varrefp) {
|
if (!varrefp) {
|
||||||
clearOptimizable(nodep, "Array select LHS isn't simple variable");
|
clearOptimizable(nodep, "Array select LHS isn't simple variable");
|
||||||
@ -719,7 +719,7 @@ private:
|
|||||||
void handleAssignSel(AstNodeAssign* nodep, AstSel* selp) {
|
void handleAssignSel(AstNodeAssign* nodep, AstSel* selp) {
|
||||||
AstVarRef* varrefp = nullptr;
|
AstVarRef* varrefp = nullptr;
|
||||||
V3Number lsb{nodep};
|
V3Number lsb{nodep};
|
||||||
iterateAndNextNull(nodep->rhsp()); // Value to assign
|
iterateAndNextConstNull(nodep->rhsp()); // Value to assign
|
||||||
handleAssignSelRecurse(nodep, selp, varrefp /*ref*/, lsb /*ref*/, 0);
|
handleAssignSelRecurse(nodep, selp, varrefp /*ref*/, lsb /*ref*/, 0);
|
||||||
if (!m_checkOnly && optimizable()) {
|
if (!m_checkOnly && optimizable()) {
|
||||||
UASSERT_OBJ(varrefp, nodep,
|
UASSERT_OBJ(varrefp, nodep,
|
||||||
@ -748,7 +748,7 @@ private:
|
|||||||
// Recurse down to find final variable being set (outVarrefp), with
|
// Recurse down to find final variable being set (outVarrefp), with
|
||||||
// lsb to be eventually set on lsbRef
|
// lsb to be eventually set on lsbRef
|
||||||
checkNodeInfo(selp);
|
checkNodeInfo(selp);
|
||||||
iterateAndNextNull(selp->lsbp()); // Bit index
|
iterateAndNextConstNull(selp->lsbp()); // Bit index
|
||||||
if (AstVarRef* const varrefp = VN_CAST(selp->fromp(), VarRef)) {
|
if (AstVarRef* const varrefp = VN_CAST(selp->fromp(), VarRef)) {
|
||||||
outVarrefpRef = varrefp;
|
outVarrefpRef = varrefp;
|
||||||
lsbRef = fetchConst(selp->lsbp())->num();
|
lsbRef = fetchConst(selp->lsbp())->num();
|
||||||
@ -798,9 +798,9 @@ private:
|
|||||||
} else if (!VN_IS(nodep->lhsp(), VarRef)) {
|
} else if (!VN_IS(nodep->lhsp(), VarRef)) {
|
||||||
clearOptimizable(nodep, "LHS isn't simple variable");
|
clearOptimizable(nodep, "LHS isn't simple variable");
|
||||||
} else if (m_checkOnly) {
|
} else if (m_checkOnly) {
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
} else if (optimizable()) {
|
} else if (optimizable()) {
|
||||||
iterateAndNextNull(nodep->rhsp());
|
iterateAndNextConstNull(nodep->rhsp());
|
||||||
if (optimizable()) {
|
if (optimizable()) {
|
||||||
AstNode* const vscp = varOrScope(VN_CAST(nodep->lhsp(), VarRef));
|
AstNode* const vscp = varOrScope(VN_CAST(nodep->lhsp(), VarRef));
|
||||||
assignOutValue(nodep, vscp, fetchValue(nodep->rhsp()));
|
assignOutValue(nodep, vscp, fetchValue(nodep->rhsp()));
|
||||||
@ -809,7 +809,7 @@ private:
|
|||||||
}
|
}
|
||||||
void visit(AstArraySel* nodep) override {
|
void visit(AstArraySel* nodep) override {
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
if (AstInitArray* const initp = VN_CAST(fetchValueNull(nodep->fromp()), InitArray)) {
|
if (AstInitArray* const initp = VN_CAST(fetchValueNull(nodep->fromp()), InitArray)) {
|
||||||
AstConst* const indexp = fetchConst(nodep->bitp());
|
AstConst* const indexp = fetchConst(nodep->bitp());
|
||||||
const uint32_t offset = indexp->num().toUInt();
|
const uint32_t offset = indexp->num().toUInt();
|
||||||
@ -826,28 +826,28 @@ private:
|
|||||||
}
|
}
|
||||||
void visit(AstBegin* nodep) override {
|
void visit(AstBegin* nodep) override {
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstNodeCase* nodep) override {
|
void visit(AstNodeCase* nodep) override {
|
||||||
if (jumpingOver(nodep)) return;
|
if (jumpingOver(nodep)) return;
|
||||||
UINFO(5, " CASE " << nodep << endl);
|
UINFO(5, " CASE " << nodep << endl);
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
if (m_checkOnly) {
|
if (m_checkOnly) {
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
} else if (optimizable()) {
|
} else if (optimizable()) {
|
||||||
iterateAndNextNull(nodep->exprp());
|
iterateAndNextConstNull(nodep->exprp());
|
||||||
bool hit = false;
|
bool hit = false;
|
||||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||||
if (!itemp->isDefault()) {
|
if (!itemp->isDefault()) {
|
||||||
for (AstNode* ep = itemp->condsp(); ep; ep = ep->nextp()) {
|
for (AstNode* ep = itemp->condsp(); ep; ep = ep->nextp()) {
|
||||||
if (hit) break;
|
if (hit) break;
|
||||||
iterateAndNextNull(ep);
|
iterateAndNextConstNull(ep);
|
||||||
if (optimizable()) {
|
if (optimizable()) {
|
||||||
V3Number match{nodep, 1};
|
V3Number match{nodep, 1};
|
||||||
match.opEq(fetchConst(nodep->exprp())->num(), fetchConst(ep)->num());
|
match.opEq(fetchConst(nodep->exprp())->num(), fetchConst(ep)->num());
|
||||||
if (match.isNeqZero()) {
|
if (match.isNeqZero()) {
|
||||||
iterateAndNextNull(itemp->stmtsp());
|
iterateAndNextConstNull(itemp->stmtsp());
|
||||||
hit = true;
|
hit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -859,7 +859,7 @@ private:
|
|||||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||||
if (hit) break;
|
if (hit) break;
|
||||||
if (!hit && itemp->isDefault()) {
|
if (!hit && itemp->isDefault()) {
|
||||||
iterateAndNextNull(itemp->stmtsp());
|
iterateAndNextConstNull(itemp->stmtsp());
|
||||||
hit = true;
|
hit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -870,7 +870,7 @@ private:
|
|||||||
// Real handling is in AstNodeCase
|
// Real handling is in AstNodeCase
|
||||||
if (jumpingOver(nodep)) return;
|
if (jumpingOver(nodep)) return;
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit(AstComment*) override {}
|
void visit(AstComment*) override {}
|
||||||
@ -878,12 +878,12 @@ private:
|
|||||||
void visit(AstStmtExpr* nodep) override {
|
void visit(AstStmtExpr* nodep) override {
|
||||||
if (jumpingOver(nodep)) return;
|
if (jumpingOver(nodep)) return;
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit(AstJumpBlock* nodep) override {
|
void visit(AstJumpBlock* nodep) override {
|
||||||
if (jumpingOver(nodep)) return;
|
if (jumpingOver(nodep)) return;
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstJumpGo* nodep) override {
|
void visit(AstJumpGo* nodep) override {
|
||||||
if (jumpingOver(nodep)) return;
|
if (jumpingOver(nodep)) return;
|
||||||
@ -898,7 +898,7 @@ private:
|
|||||||
// AstJumpGo::broken uses brokeExistsBelow() to check this.
|
// AstJumpGo::broken uses brokeExistsBelow() to check this.
|
||||||
if (jumpingOver(nodep)) return;
|
if (jumpingOver(nodep)) return;
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
if (m_jumpp && m_jumpp->labelp() == nodep) {
|
if (m_jumpp && m_jumpp->labelp() == nodep) {
|
||||||
UINFO(5, " JUMP DONE " << nodep << endl);
|
UINFO(5, " JUMP DONE " << nodep << endl);
|
||||||
m_jumpp = nullptr;
|
m_jumpp = nullptr;
|
||||||
@ -924,19 +924,19 @@ private:
|
|||||||
}
|
}
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
if (m_checkOnly) {
|
if (m_checkOnly) {
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
} else if (optimizable()) {
|
} else if (optimizable()) {
|
||||||
int loops = 0;
|
int loops = 0;
|
||||||
iterateAndNextNull(nodep->initsp());
|
iterateAndNextConstNull(nodep->initsp());
|
||||||
while (true) {
|
while (true) {
|
||||||
UINFO(5, " FOR-ITER " << nodep << endl);
|
UINFO(5, " FOR-ITER " << nodep << endl);
|
||||||
iterateAndNextNull(nodep->condp());
|
iterateAndNextConstNull(nodep->condp());
|
||||||
if (!optimizable()) break;
|
if (!optimizable()) break;
|
||||||
if (!fetchConst(nodep->condp())->num().isNeqZero()) { //
|
if (!fetchConst(nodep->condp())->num().isNeqZero()) { //
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
iterateAndNextNull(nodep->stmtsp());
|
iterateAndNextConstNull(nodep->stmtsp());
|
||||||
iterateAndNextNull(nodep->incsp());
|
iterateAndNextConstNull(nodep->incsp());
|
||||||
if (loops++ > unrollCount() * 16) {
|
if (loops++ > unrollCount() * 16) {
|
||||||
clearOptimizable(nodep, "Loop unrolling took too long; probably this is an"
|
clearOptimizable(nodep, "Loop unrolling took too long; probably this is an"
|
||||||
"infinite loop, or set --unroll-count above "
|
"infinite loop, or set --unroll-count above "
|
||||||
@ -957,22 +957,22 @@ private:
|
|||||||
}
|
}
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
if (m_checkOnly) {
|
if (m_checkOnly) {
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
} else if (optimizable()) {
|
} else if (optimizable()) {
|
||||||
int loops = 0;
|
int loops = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
UINFO(5, " WHILE-ITER " << nodep << endl);
|
UINFO(5, " WHILE-ITER " << nodep << endl);
|
||||||
iterateAndNextNull(nodep->precondsp());
|
iterateAndNextConstNull(nodep->precondsp());
|
||||||
if (jumpingOver(nodep)) break;
|
if (jumpingOver(nodep)) break;
|
||||||
iterateAndNextNull(nodep->condp());
|
iterateAndNextConstNull(nodep->condp());
|
||||||
if (jumpingOver(nodep)) break;
|
if (jumpingOver(nodep)) break;
|
||||||
if (!optimizable()) break;
|
if (!optimizable()) break;
|
||||||
if (!fetchConst(nodep->condp())->num().isNeqZero()) { //
|
if (!fetchConst(nodep->condp())->num().isNeqZero()) { //
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
iterateAndNextNull(nodep->stmtsp());
|
iterateAndNextConstNull(nodep->stmtsp());
|
||||||
if (jumpingOver(nodep)) break;
|
if (jumpingOver(nodep)) break;
|
||||||
iterateAndNextNull(nodep->incsp());
|
iterateAndNextConstNull(nodep->incsp());
|
||||||
if (jumpingOver(nodep)) break;
|
if (jumpingOver(nodep)) break;
|
||||||
|
|
||||||
// Prep for next loop
|
// Prep for next loop
|
||||||
@ -1024,7 +1024,7 @@ private:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Evaluate pin value
|
// Evaluate pin value
|
||||||
iterate(pinp);
|
iterateConst(pinp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (V3TaskConnects::iterator it = tconnects.begin(); it != tconnects.end(); ++it) {
|
for (V3TaskConnects::iterator it = tconnects.begin(); it != tconnects.end(); ++it) {
|
||||||
@ -1050,7 +1050,7 @@ private:
|
|||||||
newValue(funcp->fvarp(), &cnst);
|
newValue(funcp->fvarp(), &cnst);
|
||||||
}
|
}
|
||||||
// Evaluate the function
|
// Evaluate the function
|
||||||
iterate(funcp);
|
iterateConst(funcp);
|
||||||
m_callStack.pop_back();
|
m_callStack.pop_back();
|
||||||
if (!m_checkOnly && optimizable()) {
|
if (!m_checkOnly && optimizable()) {
|
||||||
// Grab return value from output variable (if it's a function)
|
// Grab return value from output variable (if it's a function)
|
||||||
@ -1076,7 +1076,7 @@ private:
|
|||||||
if (jumpingOver(nodep)) return;
|
if (jumpingOver(nodep)) return;
|
||||||
if (!optimizable()) return; // Accelerate
|
if (!optimizable()) return; // Accelerate
|
||||||
checkNodeInfo(nodep);
|
checkNodeInfo(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
if (m_params) {
|
if (m_params) {
|
||||||
AstNode* nextArgp = nodep->exprsp();
|
AstNode* nextArgp = nodep->exprsp();
|
||||||
|
|
||||||
@ -1139,7 +1139,7 @@ private:
|
|||||||
// We ignore isPredictOptimizable as $display is often in constant
|
// We ignore isPredictOptimizable as $display is often in constant
|
||||||
// functions and we want them to work if used with parameters
|
// functions and we want them to work if used with parameters
|
||||||
checkNodeInfo(nodep, /*display:*/ true);
|
checkNodeInfo(nodep, /*display:*/ true);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
if (m_params) {
|
if (m_params) {
|
||||||
AstConst* const textp = fetchConst(nodep->fmtp());
|
AstConst* const textp = fetchConst(nodep->fmtp());
|
||||||
switch (nodep->displayType()) {
|
switch (nodep->displayType()) {
|
||||||
@ -1171,7 +1171,7 @@ private:
|
|||||||
m_params = params;
|
m_params = params;
|
||||||
}
|
}
|
||||||
void mainGuts(AstNode* nodep) {
|
void mainGuts(AstNode* nodep) {
|
||||||
iterate(nodep);
|
iterateConst(nodep);
|
||||||
UASSERT_OBJ(!m_jumpp, m_jumpp, "JumpGo branched to label that wasn't found");
|
UASSERT_OBJ(!m_jumpp, m_jumpp, "JumpGo branched to label that wasn't found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,7 +622,7 @@ private:
|
|||||||
using ColorSet = std::unordered_set<uint32_t>;
|
using ColorSet = std::unordered_set<uint32_t>;
|
||||||
using AlwaysVec = std::vector<AstAlways*>;
|
using AlwaysVec = std::vector<AstAlways*>;
|
||||||
|
|
||||||
class IfColorVisitor final : public VNVisitor {
|
class IfColorVisitor final : public VNVisitorConst {
|
||||||
// MEMBERS
|
// MEMBERS
|
||||||
ColorSet m_colors; // All colors in the original always block
|
ColorSet m_colors; // All colors in the original always block
|
||||||
|
|
||||||
@ -636,7 +636,7 @@ class IfColorVisitor final : public VNVisitor {
|
|||||||
public:
|
public:
|
||||||
// Visit through *nodep and map each AstNodeIf within to the set of
|
// Visit through *nodep and map each AstNodeIf within to the set of
|
||||||
// colors it will participate in. Also find the whole set of colors.
|
// colors it will participate in. Also find the whole set of colors.
|
||||||
explicit IfColorVisitor(AstAlways* nodep) { iterate(nodep); }
|
explicit IfColorVisitor(AstAlways* nodep) { iterateConst(nodep); }
|
||||||
~IfColorVisitor() override = default;
|
~IfColorVisitor() override = default;
|
||||||
|
|
||||||
// METHODS
|
// METHODS
|
||||||
@ -667,12 +667,12 @@ protected:
|
|||||||
void visit(AstNodeIf* nodep) override {
|
void visit(AstNodeIf* nodep) override {
|
||||||
m_ifStack.push_back(nodep);
|
m_ifStack.push_back(nodep);
|
||||||
trackNode(nodep);
|
trackNode(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
m_ifStack.pop_back();
|
m_ifStack.pop_back();
|
||||||
}
|
}
|
||||||
void visit(AstNode* nodep) override {
|
void visit(AstNode* nodep) override {
|
||||||
trackNode(nodep);
|
trackNode(nodep);
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -269,7 +269,7 @@ public:
|
|||||||
//######################################################################
|
//######################################################################
|
||||||
// Undriven state, as a visitor of each AstNode
|
// Undriven state, as a visitor of each AstNode
|
||||||
|
|
||||||
class UndrivenVisitor final : public VNVisitor {
|
class UndrivenVisitor final : public VNVisitorConst {
|
||||||
private:
|
private:
|
||||||
// NODE STATE
|
// NODE STATE
|
||||||
// Netlist:
|
// Netlist:
|
||||||
@ -344,15 +344,15 @@ private:
|
|||||||
if (nodep->valuep()) entryp->drivenWhole();
|
if (nodep->valuep()) entryp->drivenWhole();
|
||||||
}
|
}
|
||||||
// Discover variables used in bit definitions, etc
|
// Discover variables used in bit definitions, etc
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstArraySel* nodep) override {
|
void visit(AstArraySel* nodep) override {
|
||||||
// Arrays are rarely constant assigned, so for now we punt and do all entries
|
// Arrays are rarely constant assigned, so for now we punt and do all entries
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstSliceSel* nodep) override {
|
void visit(AstSliceSel* nodep) override {
|
||||||
// Arrays are rarely constant assigned, so for now we punt and do all entries
|
// Arrays are rarely constant assigned, so for now we punt and do all entries
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstSel* nodep) override {
|
void visit(AstSel* nodep) override {
|
||||||
AstNodeVarRef* const varrefp = VN_CAST(nodep->fromp(), NodeVarRef);
|
AstNodeVarRef* const varrefp = VN_CAST(nodep->fromp(), NodeVarRef);
|
||||||
@ -375,7 +375,7 @@ private:
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// else other varrefs handled as unknown mess in AstVarRef
|
// else other varrefs handled as unknown mess in AstVarRef
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void visit(AstNodeVarRef* nodep) override {
|
void visit(AstNodeVarRef* nodep) override {
|
||||||
@ -460,7 +460,7 @@ private:
|
|||||||
VL_RESTORER(m_inBBox);
|
VL_RESTORER(m_inBBox);
|
||||||
{
|
{
|
||||||
m_inBBox = true;
|
m_inBBox = true;
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,21 +468,21 @@ private:
|
|||||||
VL_RESTORER(m_inProcAssign);
|
VL_RESTORER(m_inProcAssign);
|
||||||
{
|
{
|
||||||
m_inProcAssign = true;
|
m_inProcAssign = true;
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void visit(AstAssignDly* nodep) override {
|
void visit(AstAssignDly* nodep) override {
|
||||||
VL_RESTORER(m_inProcAssign);
|
VL_RESTORER(m_inProcAssign);
|
||||||
{
|
{
|
||||||
m_inProcAssign = true;
|
m_inProcAssign = true;
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void visit(AstAssignW* nodep) override {
|
void visit(AstAssignW* nodep) override {
|
||||||
VL_RESTORER(m_inContAssign);
|
VL_RESTORER(m_inContAssign);
|
||||||
{
|
{
|
||||||
m_inContAssign = true;
|
m_inContAssign = true;
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void visit(AstAlways* nodep) override {
|
void visit(AstAlways* nodep) override {
|
||||||
@ -495,7 +495,7 @@ private:
|
|||||||
} else {
|
} else {
|
||||||
m_alwaysCombp = nullptr;
|
m_alwaysCombp = nullptr;
|
||||||
}
|
}
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
if (nodep->keyword() == VAlwaysKwd::ALWAYS_COMB) UINFO(9, " Done " << nodep << endl);
|
if (nodep->keyword() == VAlwaysKwd::ALWAYS_COMB) UINFO(9, " Done " << nodep << endl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -504,13 +504,13 @@ private:
|
|||||||
VL_RESTORER(m_taskp);
|
VL_RESTORER(m_taskp);
|
||||||
{
|
{
|
||||||
m_taskp = nodep;
|
m_taskp = nodep;
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void visit(AstPin* nodep) override {
|
void visit(AstPin* nodep) override {
|
||||||
VL_RESTORER(m_inInoutPin);
|
VL_RESTORER(m_inInoutPin);
|
||||||
m_inInoutPin = nodep->modVarp()->isInoutish();
|
m_inInoutPin = nodep->modVarp()->isInoutish();
|
||||||
iterateChildren(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Until we support tables, primitives will have undriven and unused I/Os
|
// Until we support tables, primitives will have undriven and unused I/Os
|
||||||
@ -525,11 +525,11 @@ private:
|
|||||||
|
|
||||||
// iterate
|
// iterate
|
||||||
void visit(AstConst* nodep) override {}
|
void visit(AstConst* nodep) override {}
|
||||||
void visit(AstNode* nodep) override { iterateChildren(nodep); }
|
void visit(AstNode* nodep) override { iterateChildrenConst(nodep); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
explicit UndrivenVisitor(AstNetlist* nodep) { iterate(nodep); }
|
explicit UndrivenVisitor(AstNetlist* nodep) { iterateConst(nodep); }
|
||||||
~UndrivenVisitor() override {
|
~UndrivenVisitor() override {
|
||||||
for (UndrivenVarEntry* ip : m_entryps[1]) ip->reportViolations();
|
for (UndrivenVarEntry* ip : m_entryps[1]) ip->reportViolations();
|
||||||
for (int usr = 1; usr < 3; ++usr) {
|
for (int usr = 1; usr < 3; ++usr) {
|
||||||
|
Loading…
Reference in New Issue
Block a user