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