forked from github/verilator
Add default parameters to some Ast nodes for convenience
Also update usage to utilize. No functional change.
This commit is contained in:
parent
a9cd2998e5
commit
b22e368b25
@ -98,7 +98,7 @@ private:
|
||||
? static_cast<AstNode*>(
|
||||
new AstCMath(fl, "vlSymsp->_vm_contextp__->assertOn()", 1))
|
||||
: static_cast<AstNode*>(new AstConst(fl, AstConst::BitFalse())))),
|
||||
nodep, nullptr);
|
||||
nodep);
|
||||
newp->user1(true); // Don't assert/cover this if
|
||||
return newp;
|
||||
}
|
||||
@ -154,7 +154,7 @@ private:
|
||||
}
|
||||
|
||||
if (bodysp && passsp) bodysp = bodysp->addNext(passsp);
|
||||
ifp = new AstIf(nodep->fileline(), propp, bodysp, nullptr);
|
||||
ifp = new AstIf(nodep->fileline(), propp, bodysp);
|
||||
bodysp = ifp;
|
||||
} else if (VN_IS(nodep, Assert) || VN_IS(nodep, AssertIntrinsic)) {
|
||||
if (nodep->immediate()) {
|
||||
@ -313,8 +313,7 @@ private:
|
||||
AstIf* const ifp = new AstIf(
|
||||
nodep->fileline(), new AstLogNot(nodep->fileline(), ohot),
|
||||
newFireAssert(nodep,
|
||||
"synthesis parallel_case, but multiple matches found"),
|
||||
nullptr);
|
||||
"synthesis parallel_case, but multiple matches found"));
|
||||
ifp->branchPred(VBranchPred::BP_UNLIKELY);
|
||||
nodep->addNotParallelp(ifp);
|
||||
}
|
||||
@ -384,7 +383,7 @@ private:
|
||||
new AstLogAnd{fl, new AstLogNot{fl, newMonitorOffVarRefp(nodep, VAccess::READ)},
|
||||
new AstEq{fl, new AstConst{fl, monNum},
|
||||
newMonitorNumVarRefp(nodep, VAccess::READ)}},
|
||||
stmtsp, nullptr};
|
||||
stmtsp};
|
||||
ifp->branchPred(VBranchPred::BP_UNLIKELY);
|
||||
AstNode* const newp = new AstAlwaysPostponed{fl, ifp};
|
||||
m_modp->addStmtp(newp);
|
||||
@ -402,8 +401,7 @@ private:
|
||||
nodep->replaceWith(newsetp);
|
||||
// Add "always_comb if (__Vstrobe) begin $display(...); __Vstrobe = '0; end"
|
||||
AstNode* const stmtsp = nodep;
|
||||
AstIf* const ifp
|
||||
= new AstIf{fl, new AstVarRef{fl, varp, VAccess::READ}, stmtsp, nullptr};
|
||||
AstIf* const ifp = new AstIf{fl, new AstVarRef{fl, varp, VAccess::READ}, stmtsp};
|
||||
ifp->branchPred(VBranchPred::BP_UNLIKELY);
|
||||
AstNode* const newp = new AstAlwaysPostponed{fl, ifp};
|
||||
stmtsp->addNext(new AstAssign{fl, new AstVarRef{fl, varp, VAccess::WRITE},
|
||||
|
@ -1914,14 +1914,14 @@ private:
|
||||
bool m_pure = false; // Pure optimizable
|
||||
public:
|
||||
AstCMethodHard(FileLine* fl, AstNode* fromp, VFlagChildDType, const string& name,
|
||||
AstNode* pinsp)
|
||||
AstNode* pinsp = nullptr)
|
||||
: ASTGEN_SUPER_CMethodHard(fl, false)
|
||||
, m_name{name} {
|
||||
setOp1p(fromp);
|
||||
dtypep(nullptr); // V3Width will resolve
|
||||
addNOp2p(pinsp);
|
||||
}
|
||||
AstCMethodHard(FileLine* fl, AstNode* fromp, const string& name, AstNode* pinsp)
|
||||
AstCMethodHard(FileLine* fl, AstNode* fromp, const string& name, AstNode* pinsp = nullptr)
|
||||
: ASTGEN_SUPER_CMethodHard(fl, false)
|
||||
, m_name{name} {
|
||||
setOp1p(fromp);
|
||||
@ -4610,7 +4610,7 @@ public:
|
||||
|
||||
class AstWhile final : public AstNodeStmt {
|
||||
public:
|
||||
AstWhile(FileLine* fl, AstNode* condp, AstNode* bodysp, AstNode* incsp = nullptr)
|
||||
AstWhile(FileLine* fl, AstNode* condp, AstNode* bodysp = nullptr, AstNode* incsp = nullptr)
|
||||
: ASTGEN_SUPER_While(fl) {
|
||||
setOp2p(condp);
|
||||
addNOp3p(bodysp);
|
||||
@ -4714,7 +4714,7 @@ private:
|
||||
bool m_unique0Pragma; // unique0 case
|
||||
bool m_priorityPragma; // priority case
|
||||
public:
|
||||
AstIf(FileLine* fl, AstNode* condp, AstNode* ifsp, AstNode* elsesp = nullptr)
|
||||
AstIf(FileLine* fl, AstNode* condp, AstNode* ifsp = nullptr, AstNode* elsesp = nullptr)
|
||||
: ASTGEN_SUPER_If(fl, condp, ifsp, elsesp) {
|
||||
m_uniquePragma = false;
|
||||
m_unique0Pragma = false;
|
||||
|
@ -427,8 +427,7 @@ private:
|
||||
if (++depth > CASE_ENCODER_GROUP_DEPTH) depth = 1;
|
||||
if (depth == 1) { // First group or starting new group
|
||||
itemnextp = nullptr;
|
||||
AstIf* const newp
|
||||
= new AstIf(itemp->fileline(), ifexprp->cloneTree(true), nullptr, nullptr);
|
||||
AstIf* const newp = new AstIf(itemp->fileline(), ifexprp->cloneTree(true));
|
||||
if (groupnextp) {
|
||||
groupnextp->addElsesp(newp);
|
||||
} else {
|
||||
@ -448,7 +447,7 @@ private:
|
||||
VL_DO_DANGLING(itemexprp->deleteTree(), itemexprp);
|
||||
itemexprp = new AstConst(itemp->fileline(), AstConst::BitTrue());
|
||||
}
|
||||
AstIf* const newp = new AstIf(itemp->fileline(), itemexprp, istmtsp, nullptr);
|
||||
AstIf* const newp = new AstIf(itemp->fileline(), itemexprp, istmtsp);
|
||||
if (itemnextp) {
|
||||
itemnextp->addElsesp(newp);
|
||||
} else {
|
||||
|
@ -185,7 +185,7 @@ private:
|
||||
AstIf* makeActiveIf(AstSenTree* sensesp) {
|
||||
AstNode* const senEqnp = createSenseEquation(sensesp->sensesp());
|
||||
UASSERT_OBJ(senEqnp, sensesp, "No sense equation, shouldn't be in sequent activation.");
|
||||
AstIf* const newifp = new AstIf(sensesp->fileline(), senEqnp, nullptr, nullptr);
|
||||
AstIf* const newifp = new AstIf(sensesp->fileline(), senEqnp);
|
||||
return newifp;
|
||||
}
|
||||
void clearLastSen() {
|
||||
@ -310,8 +310,8 @@ private:
|
||||
AstNode* const origp = nodep->origp()->unlinkFrBack();
|
||||
AstNode* const changeWrp = nodep->changep()->unlinkFrBack();
|
||||
AstNode* const changeRdp = ConvertWriteRefsToRead::main(changeWrp->cloneTree(false));
|
||||
AstIf* const newp = new AstIf(
|
||||
nodep->fileline(), new AstXor(nodep->fileline(), origp, changeRdp), incp, nullptr);
|
||||
AstIf* const newp
|
||||
= new AstIf(nodep->fileline(), new AstXor(nodep->fileline(), origp, changeRdp), incp);
|
||||
// We could add another IF to detect posedges, and only increment if so.
|
||||
// It's another whole branch though versus a potential memory miss.
|
||||
// We'll go with the miss.
|
||||
|
@ -351,8 +351,7 @@ private:
|
||||
"Delayed assignment misoptimized; prev var found w/o associated IF");
|
||||
} else {
|
||||
postLogicp = new AstIf(nodep->fileline(),
|
||||
new AstVarRef(nodep->fileline(), setvscp, VAccess::READ),
|
||||
nullptr, nullptr);
|
||||
new AstVarRef(nodep->fileline(), setvscp, VAccess::READ));
|
||||
UINFO(9, " Created " << postLogicp << endl);
|
||||
finalp->addStmtp(postLogicp);
|
||||
finalp->user3p(setvscp); // Remember IF's vset variable
|
||||
|
@ -161,7 +161,7 @@ private:
|
||||
new AstCMath(funcp->fileline(),
|
||||
string("&(") + funcp->scopep()->nameVlSym() + ")",
|
||||
64)),
|
||||
returnp, nullptr);
|
||||
returnp);
|
||||
newfuncp->addStmtsp(ifp);
|
||||
} else {
|
||||
newfuncp->addStmtsp(returnp);
|
||||
|
@ -266,7 +266,7 @@ private:
|
||||
// and we also need to keep track of it for comparisons later.
|
||||
m_mgCondp = m_mgCondp->cloneTree(false);
|
||||
// Create equivalent 'if' statement and insert it before the first node
|
||||
AstIf* const resultp = new AstIf(m_mgCondp->fileline(), m_mgCondp, nullptr, nullptr);
|
||||
AstIf* const resultp = new AstIf(m_mgCondp->fileline(), m_mgCondp);
|
||||
m_mgFirstp->addHereThisAsNext(resultp);
|
||||
// Unzip the list and insert under branches
|
||||
AstNode* nextp = m_mgFirstp;
|
||||
|
@ -367,7 +367,7 @@ private:
|
||||
AstNode* const condp
|
||||
= new AstAnd(fl, select(fl, outputAssignedTableVscp, indexVscp),
|
||||
new AstConst(fl, outputChgMask));
|
||||
outsetp = new AstIf(fl, condp, outsetp, nullptr);
|
||||
outsetp = new AstIf(fl, condp, outsetp);
|
||||
}
|
||||
|
||||
stmtsp->addNext(outsetp);
|
||||
|
@ -656,7 +656,7 @@ private:
|
||||
condp = condp ? new AstOr(flp, condp, selp) : selp;
|
||||
}
|
||||
}
|
||||
ifp = new AstIf(flp, condp, nullptr, nullptr);
|
||||
ifp = new AstIf(flp, condp);
|
||||
if (!always) ifp->branchPred(VBranchPred::BP_UNLIKELY);
|
||||
subFuncp->addStmtsp(ifp);
|
||||
subStmts += ifp->nodeCount();
|
||||
|
@ -127,8 +127,7 @@ private:
|
||||
(needDly ? static_cast<AstNode*>(
|
||||
new AstAssignDly(fl, prep, new AstVarRef(fl, varp, VAccess::READ)))
|
||||
: static_cast<AstNode*>(
|
||||
new AstAssign(fl, prep, new AstVarRef(fl, varp, VAccess::READ)))),
|
||||
nullptr);
|
||||
new AstAssign(fl, prep, new AstVarRef(fl, varp, VAccess::READ)))));
|
||||
newp->branchPred(VBranchPred::BP_LIKELY);
|
||||
newp->isBoundsCheck(true);
|
||||
if (debug() >= 9) newp->dumpTree(cout, " _new: ");
|
||||
|
@ -1366,7 +1366,7 @@ private:
|
||||
switch (nodep->attrType()) {
|
||||
case VAttrType::DIM_SIZE: {
|
||||
AstNode* const newp = new AstCMethodHard(
|
||||
nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size", nullptr);
|
||||
nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size");
|
||||
newp->dtypeSetSigned32();
|
||||
newp->didWidth(true);
|
||||
newp->protect(false);
|
||||
@ -1384,7 +1384,7 @@ private:
|
||||
case VAttrType::DIM_RIGHT:
|
||||
case VAttrType::DIM_HIGH: {
|
||||
AstNode* const sizep = new AstCMethodHard(
|
||||
nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size", nullptr);
|
||||
nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size");
|
||||
sizep->dtypeSetSigned32();
|
||||
sizep->didWidth(true);
|
||||
sizep->protect(false);
|
||||
@ -2676,8 +2676,8 @@ private:
|
||||
if (nodep->name() == "num" // function int num()
|
||||
|| nodep->name() == "size") {
|
||||
methodOkArguments(nodep, 0, 0);
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size",
|
||||
nullptr); // So don't need num()
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(),
|
||||
"size"); // So don't need num()
|
||||
newp->dtypeSetSigned32();
|
||||
} else if (nodep->name() == "first" // function int first(ref index)
|
||||
|| nodep->name() == "last" //
|
||||
@ -2703,7 +2703,7 @@ private:
|
||||
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE);
|
||||
if (!nodep->pinsp()) {
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(),
|
||||
"clear", nullptr);
|
||||
"clear");
|
||||
newp->makeStatement();
|
||||
} else {
|
||||
AstNode* const index_exprp = methodCallAssocIndexExpr(nodep, adtypep);
|
||||
@ -2731,7 +2731,7 @@ private:
|
||||
methodOkArguments(nodep, 0, 0);
|
||||
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ);
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(),
|
||||
nodep->name(), nullptr);
|
||||
nodep->name());
|
||||
if (nodep->name() == "unique_index") {
|
||||
newp->dtypep(queueDTypeIndexedBy(adtypep->keyDTypep()));
|
||||
} else {
|
||||
@ -2794,19 +2794,16 @@ private:
|
||||
if (nodep->name() == "at") { // Created internally for []
|
||||
methodOkArguments(nodep, 1, 1);
|
||||
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE);
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "at",
|
||||
nullptr);
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "at");
|
||||
newp->dtypeFrom(adtypep->subDTypep());
|
||||
} else if (nodep->name() == "size") {
|
||||
methodOkArguments(nodep, 0, 0);
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size",
|
||||
nullptr);
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size");
|
||||
newp->dtypeSetSigned32();
|
||||
} else if (nodep->name() == "delete") { // function void delete()
|
||||
methodOkArguments(nodep, 0, 0);
|
||||
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE);
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "clear",
|
||||
nullptr);
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "clear");
|
||||
newp->makeStatement();
|
||||
} else if (nodep->name() == "and" || nodep->name() == "or" || nodep->name() == "xor"
|
||||
|| nodep->name() == "sum" || nodep->name() == "product") {
|
||||
@ -2837,7 +2834,7 @@ private:
|
||||
methodOkArguments(nodep, 0, 0);
|
||||
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ);
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(),
|
||||
nodep->name(), nullptr);
|
||||
nodep->name());
|
||||
if (nodep->name() == "unique_index") {
|
||||
newp->dtypep(newp->findQueueIndexDType());
|
||||
} else {
|
||||
@ -2883,27 +2880,25 @@ private:
|
||||
if (nodep->name() == "at") { // Created internally for []
|
||||
methodOkArguments(nodep, 1, 1);
|
||||
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE);
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "at",
|
||||
nullptr);
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "at");
|
||||
newp->dtypeFrom(adtypep->subDTypep());
|
||||
} else if (nodep->name() == "num" // function int num()
|
||||
|| nodep->name() == "size") {
|
||||
methodOkArguments(nodep, 0, 0);
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size",
|
||||
nullptr);
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size");
|
||||
newp->dtypeSetSigned32();
|
||||
} else if (nodep->name() == "delete") { // function void delete([input integer index])
|
||||
methodOkArguments(nodep, 0, 1);
|
||||
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE);
|
||||
if (!nodep->pinsp()) {
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(),
|
||||
"clear", nullptr);
|
||||
"clear");
|
||||
newp->makeStatement();
|
||||
} else {
|
||||
AstNode* const index_exprp = methodCallQueueIndexExpr(nodep);
|
||||
if (index_exprp->isZero()) { // delete(0) is a pop_front
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(),
|
||||
"pop_front", nullptr);
|
||||
"pop_front");
|
||||
newp->dtypeFrom(adtypep->subDTypep());
|
||||
newp->makeStatement();
|
||||
} else {
|
||||
@ -2933,7 +2928,7 @@ private:
|
||||
// Returns element, so method both consumes (reads) and modifies the queue
|
||||
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READWRITE);
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(),
|
||||
nodep->name(), nullptr);
|
||||
nodep->name());
|
||||
newp->dtypeFrom(adtypep->subDTypep());
|
||||
if (!nodep->firstAbovep()) newp->makeStatement();
|
||||
} else if (nodep->name() == "push_back" || nodep->name() == "push_front") {
|
||||
@ -2972,7 +2967,7 @@ private:
|
||||
methodOkArguments(nodep, 0, 0);
|
||||
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ);
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(),
|
||||
nodep->name(), nullptr);
|
||||
nodep->name());
|
||||
if (nodep->name() == "unique_index") {
|
||||
newp->dtypep(newp->findQueueIndexDType());
|
||||
} else {
|
||||
@ -3850,8 +3845,7 @@ private:
|
||||
} else if (VN_IS(fromDtp, DynArrayDType) || VN_IS(fromDtp, QueueDType)) {
|
||||
if (varp) {
|
||||
auto* const leftp = new AstConst{fl, AstConst::Signed32{}, 0};
|
||||
auto* const sizep
|
||||
= new AstCMethodHard{fl, fromp->cloneTree(false), "size", nullptr};
|
||||
auto* const sizep = new AstCMethodHard{fl, fromp->cloneTree(false), "size"};
|
||||
sizep->dtypeSetSigned32();
|
||||
sizep->didWidth(true);
|
||||
sizep->protect(false);
|
||||
|
@ -3111,7 +3111,7 @@ statement_item<nodep>: // IEEE: statement_item
|
||||
//
|
||||
// // IEEE: conditional_statement
|
||||
| unique_priorityE yIF '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE
|
||||
{ AstIf* const newp = new AstIf{$2, $4, $6, nullptr};
|
||||
{ AstIf* const newp = new AstIf{$2, $4, $6};
|
||||
$$ = newp;
|
||||
if ($1 == uniq_UNIQUE) newp->uniquePragma(true);
|
||||
if ($1 == uniq_UNIQUE0) newp->unique0Pragma(true);
|
||||
@ -3180,7 +3180,7 @@ statement_item<nodep>: // IEEE: statement_item
|
||||
$$ = $2->cloneTree(true);
|
||||
$$->addNext(new AstWhile($1,$5,$2));
|
||||
}
|
||||
else $$ = new AstWhile($1,$5,nullptr); }
|
||||
else $$ = new AstWhile($1,$5); }
|
||||
// // IEEE says array_identifier here, but dotted accepted in VMM and 1800-2009
|
||||
| yFOREACH '(' idClassSelForeach ')' stmtBlock { $$ = new AstForeach($1, $3, $5); }
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user